Field Dialog
Brian Element
This code creates a menu that allows you to pick multiple fields. The code should be inserted as part of the menu structure and as part of the menu, usually based on a select statement option of a button being selected from the main menu.
Snippet
'code to creat the dialog
Begin Dialog dlgFields 0,40,326,157,"Select Fields", .NewDialog ListBox 11,24,134,90, FieldList$(), .ListBox1 OKButton 96,121,40,14, "OK", .OKButton1 CancelButton 184,122,40,14, "Cancel", .CancelButton1 ListBox 176,26,134,89, FieldList1$(), .ListBox2 PushButton 154,31,15,14, ">", .PushButton1 PushButton 154,53,15,14, "<", .PushButton1 PushButton 154,73,15,14, ">>", .PushButton1 PushButton 154,94,15,13, "<<", .PushButton1 Text 12,11,79,11, "Fields in selected file", .Text1 Text 178,13,101,11, "Fields to be used in cross join file", .Text2 End Dialog
'-------------------------------------------------
'the following code would usually be called from withint a select
'case statement to display the dialog. The arrays of pirmaryFields()
'should have already been created with the field information
'and an integer called primaryNoFields with the total number of fields
If primaryFileName = "" Then MsgBox "Please select the primary file", 48, "Error" GoTo main_menu: End If tempFieldPopulated = false ReDim FieldList1$(primaryNoFields) ReDim fieldlist$(primaryNoFields) For i = 1 To primaryNoFields fieldlist$(i) = primaryFields(i) If primaryUseField(i) = true Then FieldList1$(i) = primaryFields(i) Else FieldList1$(i) = "" End If Next i field_menu: buttonPrimaryFields = Dialog(DlgFields1) If buttonPrimaryFields = 1 Then FieldList1$(DlgFields1.ListBox1 + 1) = fieldlist$(DlgFields1.ListBox1 + 1) GoTo field_menu End If If buttonPrimaryFields = 2 Then 'cycles through the choices and takes out the proper item j = 0 For i = 1 To primaryNoFields If FieldList1$(i) <> "" Then j = j + 1 If j = DlgFields1.ListBox2 + 1 Then FieldList1$(i) = "" End If End If Next i GoTo field_menu End If If buttonPrimaryFields = 3 Then For i=1 To primaryNoFields FieldList1$(i)= fieldlist$(i) Next i GoTo field_menu End If If buttonPrimaryFields = 4 Then For i=1 To primaryNoFields FieldList1$(i)= "" Next i GoTo field_menu End If If buttonPrimaryFields = -1 Then 'check to make sure there is something in the list box
For i = 1 To primaryNoFields If FieldList1$(i) <> "" Then tempFieldPopulated = true primaryUseField(i) = true Else primaryUseField(i) = false End If Next i If tempFieldPopulated = false Then MsgBox "You must select at least one field" GoTo field_menu End If End If GoTo main_menu