i want to determine the user selection before displaying userform.
Basically, user is given the choice to choose between the followings (through command buttons in Sheet 1)
1. Modify Database
2. Create Report
there are forms associated with option 1 and 2 plus there is one more form that acts as a go between the user clicking the command button in excel sheet and the display of the appropriate form. This go between form is Choose Database form.
Because both options require user to choose database, im having difficulties in determining which option the user chose, so that when the user has chosen the database, the appropriate form will be displayed.
Here are snippets of the codes currently behind the all those buttons and form:
This is from Sheet 1
CODE
Private Sub cmdModifyDB_Click()
Dim searchExt As String
Dim searchResult As Variant
Dim i As Integer
searchExt = ThisWorkbook.Path & "\*.mdb"
searchResult = GetFileList(searchExt)
Select Case IsArray(searchResult)
Case True 'files found
For i = LBound(searchResult) To UBound(searchResult)
ChooseDBForm.lbDBSelected.AddItem searchResult(i)
Next i
ChooseDBForm.Show
Case False 'no files found
MsgBox "No Database Exists"
ChooseDBForm.Hide
End Select
End Sub
Private Sub cmdCreateReport_Click()
Dim searchExt As String
Dim searchResult As Variant
Dim i As Integer
searchExt = ThisWorkbook.Path & "\*.mdb"
searchResult = GetFileList(searchExt)
Select Case IsArray(searchResult)
Case True 'files found
For i = LBound(searchResult) To UBound(searchResult)
ChooseDBForm.lbDBSelected.AddItem searchResult(i)
Next i
ChooseDBForm.Show
Case False 'no files found
MsgBox "No Database Exists"
ChooseDBForm.Hide
End Select
End Sub
Dim searchExt As String
Dim searchResult As Variant
Dim i As Integer
searchExt = ThisWorkbook.Path & "\*.mdb"
searchResult = GetFileList(searchExt)
Select Case IsArray(searchResult)
Case True 'files found
For i = LBound(searchResult) To UBound(searchResult)
ChooseDBForm.lbDBSelected.AddItem searchResult(i)
Next i
ChooseDBForm.Show
Case False 'no files found
MsgBox "No Database Exists"
ChooseDBForm.Hide
End Select
End Sub
Private Sub cmdCreateReport_Click()
Dim searchExt As String
Dim searchResult As Variant
Dim i As Integer
searchExt = ThisWorkbook.Path & "\*.mdb"
searchResult = GetFileList(searchExt)
Select Case IsArray(searchResult)
Case True 'files found
For i = LBound(searchResult) To UBound(searchResult)
ChooseDBForm.lbDBSelected.AddItem searchResult(i)
Next i
ChooseDBForm.Show
Case False 'no files found
MsgBox "No Database Exists"
ChooseDBForm.Hide
End Select
End Sub
'These are the codes behind ChooseDBForm
CODE
Private Sub cmdCancel_Click()
Unload ChooseDBForm
End Sub
Private Sub cmdOK_Click()
'check if database is selected from the listbox
If lbDBSelected.listIndex = -1 Then
MsgBox "You have not selected any database to be accessed. Please choose from the database(s) listed above"
Else
ModifyRecordsForm.lblDBName.Caption = lbDBSelected.Value
DBPath = ThisWorkbook.Path
DBName = "\" & lbDBSelected.Value
DBFullPathName = DBPath & DBName
Unload ChooseDBForm
OpenConn (DBFullPathName)
PopulateRecords
ModifyRecordsForm.Show
End If
End Sub
As you can see, i have not taken into account if the user chooses to create report instead, coz i do not know how to.....
thank you sooo much!
ted.