ComboBox / Command Button / Form Help!!!!!!

  • Thread starter Thread starter Chris
  • Start date Start date
C

Chris

I have a form with a combo box with a list of names (queried from a
table) and a command button I want to be able to select a name from
the combo box, then click (or press "enter" on) a command button ,
which will open a seperate form that corresponds with that individual
name. There are 4 names and 1 unique form for each name. Any
suggestions on how I might be able to achieve this? Thank you
 
Chris,

In the Click event of the command button, try using a Select Case statement.

Select Case Me.NameOfComboBox
Case "One of the Names"
'open the correct form
docmd.openform "FormName"
Case "Another one of the Names"
'open the correct form
docmd.openform "FormName"
'repeate each case statement for each name, opening the correct form

End Select

Keep in mind that the code above does nothing else but open the desired form
based on the selection made from the combo box.
 
Chris,

In the Click event of the command button, try using a Select Case statement.

Select Case Me.NameOfComboBox
Case "One of the Names"
'open the correct form
docmd.openform "FormName"
Case "Another one of the Names"
'open the correct form
docmd.openform "FormName"
'repeate each case statement for each name, opening the correct form

End Select

Keep in mind that the code above does nothing else but open the desired form
based on the selection made from the combo box.

--
HTH

Mr B
askdoctoraccess dot com





- Show quoted text -

Thanks you Mr B for a very prompt and correct response. This code did
exactly what I was looking for.

Thanks Again!
 
Chris said:
I have a form with a combo box with a list of names (queried from a
table) and a command button I want to be able to select a name from
the combo box, then click (or press "enter" on) a command button ,
which will open a seperate form that corresponds with that individual
name. There are 4 names and 1 unique form for each name. Any
suggestions on how I might be able to achieve this? Thank you

Add another column to your table with the form name, and then add the
column to your combo box. (Width = 0)

Private Sub cmdOpenForm_Click()
DoCmd.OpenForm Me.NameOfComboBox.Column(1)
End Sub

Then, as you add more forms, you can just update the table to open
those forms.
HTH,
Chris M.
 
Back
Top