opening form

Jon123

Registered User.
Local time
Today, 14:46
Joined
Aug 29, 2003
Messages
668
I have a combo box with 4 choices and it is limited to the list. Based on the value the user selects I want to open 1 of 4 forms. Tried using the select case but does not work?

any suggestions?

Jon
 
Just refer to the combo's value.

For example: Your combo's name is 'lstForms'

If Me.lstForms.Value = "Value 1" then DoCmd.OpenForm "Form 1"
If Me.lstForms.Value = "Value 2" then DoCmd.OpenForm "Form 2"
If Me.lstForms.Value = "Value 3" then DoCmd.OpenForm "Form 3"
If Me.lstForms.Value = "Value 4" then DoCmd.OpenForm "Form 4"

You could put this code in the lists AfterUpdate() property or link it to a button.

Greetz,

Seth
 
The select case method is more efficient. Enclose your value in quotes if it is a text value, no quotes if numeric. Also, the value you are testing is the value that the combo box is bound to.

Code:
    Select Case YourComboBoxNameHere
        Case "Form 1"
            DoCmd.OpenForm "Form 1"
        Case "Form 2"
            DoCmd.OpenForm "Form 2"
        Case "Form 3"
            DoCmd.OpenForm "Form 3"
        Case "Form 4"
            DoCmd.OpenForm "Form 4"
        Case Else
            MsgBox "Please select a valid form to open!", vbCritical, "Invalid Form"
            Exit Sub
    End Select
 

Users who are viewing this thread

Back
Top Bottom