I'm putting together a simple record-viewer. It reads thousands of records from a .CSV and allows the user to view and annotate each individual record. Each record will display on ONE panel, and the user will scroll down to complete the review, and at the bottom of the form there will be a number of controls that they will select.
Each record contains about 350 fields, but I'm only displaying about 100 at this time.
Just for help in visualizing this, here's a troubleshooting function that concatenates all the current fieldnames into one string.
Function ConcatRawHeader () As String
Local x As String
Local i, FieldCount, LineLenMax, LineCnt As Long
FieldCount = DataCount
'MsgBox Str$( FieldCount),,"Field Count via DATACOUNT"
ReDim gFieldNames(1 To FieldCount)
LineLenMax = 100 : LineCnt = 1
For i = 1 To FieldCount
gFieldNames(i) = Read$(i)
'MsgBox gFieldNames(i),,"gFieldNames(" & Str$(i) & ")"
x = x & $Dq & gFieldNames(i) & $Dq & ","
If Len(x) >= LineLenMax * LineCnt Then
x = x & $CrLf
Incr LineCnt
End If
Next i
x = RTrim$(x, ",")
'MsgBox Str$(i),,"Ending index of i" 'this ends at 1 higher than loops
Function = x
'this is where the function exits...
Data "Company Name"
Data "Executive First Name","Executive Last Name","Executive Title","Executive Gender"
Data "Address","City","Phone Number Combined","Toll Free Number Combined","Website","Company Description"
Data "Primary SIC Code","Primary SIC Description"
Data "SIC Code 1","SIC Code 1 Description","SIC Code 2","SIC Code 2 Description"
Data "SIC Code 3","SIC Code 3 Description","SIC Code 4","SIC Code 4 Description"
Data "Primary NAICS","Primary NAICS Description","NAICS 1","NAICS 1 Description"
Data "Franchise Description 1","Franchise Description 2","Franchise Description 3"
Data "Cuisine Code Description"
Data "Location Employee Size Range","Location Employee Size Actual","Location Sales Volume Range","Location Sales Volume Actual"
Data "Corporate Employee Size Range","Corporate Employee Size Actual","Corporate Sales Volume Range","Corporate Sales Volume Actual"
Data "Type Of Business","Location Type","IUSA Number","Parent IUSA Number","Subsidiary IUSA Number","Foreign Parent Flag"
Data "EIN 1","EIN 2","EIN 3","Fortune 1000 Ranking","Credit Cards Accepted","Square Footage","Number Of PC's","Home Business"
Data "Credit Score Alpha","Government Office","Import Export Flag","Own Or Lease","Firm Or Individual"
Data "Monday Open","Monday Close","Tuesday Open","Tuesday Close","Wednesday Open","Wednesday Close","Thursday Open","Thursday Close"
Data "Friday Open","Friday Close","Saturday Open","Saturday Close","Sunday Open","Sunday Close"
Data "Executive First Name 1","Executive Last Name 1","Executive Title 1","Executive Gender 1"
Data "Ticker Symbol","Stock Exchange"
Data "Accounting Expenses","Advertising Expenses","Computer Expenses","Contract Labor Expenses","Insurance Expenses","Legal Expenses"
Data "Office Supplies Expense","Management/Administration Expenses","Package Container Expense","Payroll And Benefits Expenses"
Data "Purchase Print Expenses","Rent Expenses","Telcom Expenses","Utilities Expenses"
Data "Location Sales History Year 1","Location Sales History Year 2"
Data "Location Employee History Year 1","Location Employee History Year 2"
Data "Corporate Employees History Year 1","Corporate Employees History Year 2"
Data "Corporate Sales History Year 1","Corporate Sales History Year 2"
End Function
I am manually creating a textbox for each field, and being so repetitious and prone to error and mis-alignment, I was wondering if there's a built-in way I could accomplish this more easily, or even a way I could edit the .FRM file to insert blocks of code. Or, can I have FF create the form dynamically?
All I know is to select TEXTBOX from the Workspace, draw the control, go back to Workspace and select TEXTBOX again, repeat, repeat, etc. Then I have to size the controls, AND THEN...change the names... (I use the notation of: txtCompanyName and txtCorporateSalesHistoryYear2)
Seeing that I already have all the fieldnames, and that they're already in text as delimited strings, I figure there HAS to be an easier way...
I appreciate any thoughts!
-John
OK, well, I've played with this a bit...
I went into my frmMain.frm and located the descriptors for the last textbox that I had added on the form using the normal FF graphical interface. It looks like this:
[ControlType] TextBox | PropertyCount=22 | zorder=5 | tabindex=6 |
name=Text5
windowstyles=WS_CHILD, WS_VISIBLE, WS_TABSTOP, ES_LEFT, ES_AUTOHSCROLL|WS_EX_CLIENTEDGE, WS_EX_LEFT, WS_EX_LTRREADING, WS_EX_RIGHTSCROLLBAR
backcolor=SYS,5
controlindex=0
font=Segoe UI,9,0
fontupgrade=False
forecolor=SYS,8
height=22
left=510
locked=False
leftmargin=0
maxlength=0
rightmargin=0
resizerules=
seltext=False
text=Text5
tag=
tag2=
tooltip=
tooltipballoon=False
top=42
width=72
I copied it 5 more times, changed the values for "top=" "left=" and where needed, "width=".
I set the "left=" value of the next control to be the previous control's "left=" plus "width=" plus a little space...
So, now I know I can automate this fairly easily, and set the "name=" for each field as well.
If I do this in a separate text file, I can review and adjust it, then just drop the whole thing into frmMain.frm just before the "[AllCode]" marker.
Does anyone see any problem with this approach? Anything downstream that FF won't like?
Thanks,
-John
Rather than a form have you thought about using a Listview with editable fields?
I know the "standard" thought process would be for each field to be across in columns as one line but nothing says it has to be. You could easily make each field it's own row. This allows flexibility for any number of fields you want and very little code complexity.
Similar to something like this (took less than 10 mins to build so it's easy to implement)...
(https://www.planetsquires.com/protect/forum/proxy.php?request=http%3A%2F%2Fwww.blecktech.com%2Fimages%2Feditablelistview.jpg&hash=1c3b6e05ad9b0d9402667c8210e968a293ea6368)
I did think about that, especially where there are duplicate fields that are numbered (NAICS 1, NAICS 2, NAICS 3, etc.), and I'll probably turn those into listboxes at some point.
But the users need to see as much as possible at a time, so I'm reducing vertical scrolling by packing the fields in logical rows.
I just finished my first draft of code that interprets the FieldNames and creates the FF "descriptors", edited it into frmMain.frm, and opened the project. So far, I can't detect any complaints from FF.
All the fields are in there and ready for the next step - reading the data in...
SO, my conclusion is that for this kind of "massively repetitious fields" on one form, editing the .FRM file is THE way to go!!!
-JohnM
Have you tried control arrays? Create one textbox, copy it, paste it. FF asks if you want to create a control array. Say yes. Copy those two and paste them. Copy those four.... You get the picture. It can take a bit of playing with them to figure out how FF handles them. But once you figure it out, they are easy to use. You could also just create them in code at run-time. Just copy that one control you found in the .FRM file and put it in a sub or function in your code. Then call it as many times as you wish, changing some of the options (x,y location mainly) before creating each one.
I agree with George though. I would use a ListView (report mode of course).
David
I've never tried to create controls "en masse" in code like that... I'll have to play with it, as it WOULD be a better solution... thanks for the suggestion.
-JohnM