colinmitton
Technical User
I have a set up a search box to find businesses in a database.
The code looks like this:
Private Sub cmdSearch_Click()
Dim varWhere As Variant
varWhere = Null
If Not IsNothing(Me.txtCompany) Then
varWhere = "[3rdPartyBusinessName] LIKE '" & Me.txtCompany & "*'"
End If
If Not IsNothing(Me.txtTown) Then
varWhere = "[City] LIKE '" & Me.txtTown & "*'"
End If
If Not IsNothing(Me.cmbType) Then
varWhere = (varWhere + " AND ") & "[BusinessTypes] = " & Me.cmbType
End If
If IsNothing(varWhere) Then
MsgBox "You must enter at least one search criteria.", vbInformation, gstrAppTitle
Exit Sub
End If
DoCmd.OpenForm "frm_3rd_P_Bus_Res", WhereCondition:=varWhere
DoCmd.Close acForm, Me.Name
This worked fine until I decided to add a 'sub form' so I could select from a list of multiple results. The sub form is called: frm_QLookup_3rd_P_Business and is in the form frm_3rd_P_Bus_Res
How do I get me where condition to talk to 'sub form' element? I tried adjusting the if statement like so:
If Not IsNothing(Me.txtCompany) Then
varWhere = "[frm_3rd_P_Bus_Res!frm_QLookup_3rd_P_Business!3rdPartyBusinessName] LIKE '" & Me.txtCompany & "*'"
End If
Any ideas?
The code looks like this:
Private Sub cmdSearch_Click()
Dim varWhere As Variant
varWhere = Null
If Not IsNothing(Me.txtCompany) Then
varWhere = "[3rdPartyBusinessName] LIKE '" & Me.txtCompany & "*'"
End If
If Not IsNothing(Me.txtTown) Then
varWhere = "[City] LIKE '" & Me.txtTown & "*'"
End If
If Not IsNothing(Me.cmbType) Then
varWhere = (varWhere + " AND ") & "[BusinessTypes] = " & Me.cmbType
End If
If IsNothing(varWhere) Then
MsgBox "You must enter at least one search criteria.", vbInformation, gstrAppTitle
Exit Sub
End If
DoCmd.OpenForm "frm_3rd_P_Bus_Res", WhereCondition:=varWhere
DoCmd.Close acForm, Me.Name
This worked fine until I decided to add a 'sub form' so I could select from a list of multiple results. The sub form is called: frm_QLookup_3rd_P_Business and is in the form frm_3rd_P_Bus_Res
How do I get me where condition to talk to 'sub form' element? I tried adjusting the if statement like so:
If Not IsNothing(Me.txtCompany) Then
varWhere = "[frm_3rd_P_Bus_Res!frm_QLookup_3rd_P_Business!3rdPartyBusinessName] LIKE '" & Me.txtCompany & "*'"
End If
Any ideas?