T
Tony Williams
I want to build a search form. The search form will have one unbound combo
box "cmbcompany" which is based on a table "tblcompany" and another unbound
combo box "cmbmonth" (a date field format "mmmmyyyy") based on a table
"tblmonth" When the user has selected both combo boxes they will click on a
command button "cmdopen" which will open a form "frmfda" where "cmbmonth" is
equal to "txtmonthlabela" on the form and "cmbcompany" is equal to
"txtcompany" which is on the subform "subformFDA" which is part of the main
form "frmfda" I have tried adapting this code but can't see how I can add
the reference to the month and the subform.
Dim strform As String 'Name of form to open.
Dim strWhere As String 'Where condition for OpenForm.
strField = "txtcompany"
If Not IsNull(Me.cmbcompany) Then
strWhere = strWhere & " AND txtCompany = """ & Me.cmbcompany & """"
End If
strWhere = Mid(strWhere, 6) 'get rid of extra AND
Debug.Print strWhere 'For debugging purposes only.
DoCmd.OpenForm "frmFDA", acNormal, , strWhere
Can anyone help me to modify this code or is there a better way?
Thanks
Tony
box "cmbcompany" which is based on a table "tblcompany" and another unbound
combo box "cmbmonth" (a date field format "mmmmyyyy") based on a table
"tblmonth" When the user has selected both combo boxes they will click on a
command button "cmdopen" which will open a form "frmfda" where "cmbmonth" is
equal to "txtmonthlabela" on the form and "cmbcompany" is equal to
"txtcompany" which is on the subform "subformFDA" which is part of the main
form "frmfda" I have tried adapting this code but can't see how I can add
the reference to the month and the subform.
Dim strform As String 'Name of form to open.
Dim strWhere As String 'Where condition for OpenForm.
strField = "txtcompany"
If Not IsNull(Me.cmbcompany) Then
strWhere = strWhere & " AND txtCompany = """ & Me.cmbcompany & """"
End If
strWhere = Mid(strWhere, 6) 'get rid of extra AND
Debug.Print strWhere 'For debugging purposes only.
DoCmd.OpenForm "frmFDA", acNormal, , strWhere
Can anyone help me to modify this code or is there a better way?
Thanks
Tony