|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Combo Help
Hi all,
I have a combo box with three rows.. one for corporation, partneship and Individual. I want depending on my selection in combo box..the respective form to open. Can anyone help. Does the following procedure right..was just juggling around..i am not good at VB.(PLEASE IGNORE IF THE FOLLOWING DOESNOT MAKE SENSE) Private Sub Command3_Click() On Error GoTo Err_Command3_Click Dim stDocName As String Dim stLinkCriteria As String If stDocName = "Corporation" Then stDocName = "Corporation" DoCmd.OpenForm stDocName, , , stLinkCriteria If stDocName = "Partnership" Then stDocName = "Partnership" DoCmd.OpenForm stDocName, , , stLinkCriteria If stDocName = "DBA" Then stDocName = "DBA" DoCmd.OpenForm stDocName, , , stLinkCriteria Else Exit_Command3_Click: Exit Sub Err_Command3_Click: MsgBox Err.Description Resume Exit_Command3_Click End Sub Thank you for your help |
|
#2
|
|||
|
|||
|
Hi Rishy,
You are on the right track. Declare your selection from your combobox and use the results of that selection in your criteria for your IF statement Dim strSelection As String strSelection = Combobox.Value If strSelection = "Corporation" Then stDocName = "Corporation" DoCmd.OpenForm stDocName ElseIf strSelection = "Partnership" Then stDocName = "Partnership" DoCmd.OpenForm stDocName ElseIf strSelection = "DBA" Then stDocName = "DBA" DoCmd.OpenForm stDocName End If Or use the Select Case method Select Case strSelection Case "Corporation" stDocName = "Corporation" DoCmd.OpenForm stDocName Case "Partnership" stDocName = "Partnership" DoCmd.OpenForm stDocName Case "DBA" stDocName = "DBA" DoCmd.OpenForm stDocName End Select The Select Case runs faster than trying to evaluate all the IF Then statements, but would not be noticable in this instance when using just the three variables. lwells |
|
#3
|
|||
|
|||
|
Thank you Iwells, when i am using the following code, it is asking me for the macro name...can you please say what am i doing wrong..the following is the code i am using for on click event.
Private Sub Command4_Click() On Error GoTo Err_Command4_Click Dim stDocName As String Dim stLinkCriteria As String Dim strSelection As String strSelection = ComboBox.Value If strSelection = "Corporation" Then stDocName = "Corporation" DoCmd.OpenForm stDocName ElseIf strSelection = "Partnership" Then stDocName = "Partnership" DoCmd.OpenForm stDocName ElseIf strSelection = "DBA" Then stDocName = "DBA" DoCmd.OpenForm stDocName End If Exit_Command4_Click: Exit Sub Err_Command4_Click: MsgBox Err.Description Resume Exit_Command4_Click End Sub Quote:
|
|
#4
|
|||
|
|||
|
Hi Rishy,
You need to put the correct name of your combo box in this statement strSelection = "CorrectNameOfTheComboBox".Value Also make sure of your correct form name for the stDocName = "CorrectNameOfForm" lwells |
![]() |
| Viewing: Dev Articles Community Forums > Databases > Microsoft Access Development > Combo Help |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|