What he means is that the combo box will have the form name displayed, and you take the form name from the combo box when the user clicks the button to open the form.
So if your combo boc was called "cboComboBox" then you would want the value or text displayed in the combo box. That is your form name. So using the DoCmd to open the form, your command would be:
DoCmd.OpenForm cboComboBox.Text
Another way to do this is to declare variables, assign values to the variables, and use the variable to open the form, as Access wizards do. That would be a longer way around like this:
Dim stDocName As String
stDocName = Me.cboComboBox
DoCmd.OpenForm stDocName
Neither of these account for users clicking the button without selecting a form. That would be:
Dim stDocName As String
If IsNull(Me.cboComboBox) Or Me.cboComboBox = "" Then
MsgBox("Please select a form to open")
Exit Sub
Else
stDocName = Me.cboComboBox
End If
DoCmd.OpenForm stDocName
A better solution might be to have a seperate button for each form and just use the button wizard to open the forms.
HTH
mmcdonal
|