Hello, I'm trying to create a search dialog box which will display a table of matching records and allow you to pick the one you would like to view.
I can't seem to get it to work and was wondering if anyone has any suggestions. I've added comments in red.
Thanks
gogirl
I can't seem to get it to work and was wondering if anyone has any suggestions. I've added comments in red.
Code:
Private Sub Search_Click()
Const cInvalidDataError As String = "You have entered an invalid date."
Dim strWhere As String
Dim strError As String
strWhere = "1=1"
' If Company
If Nz(Me.CUST_NM) <> "" Then
'Create Predicate
strWhere = strWhere & " AND " & "CUST_NM = " & Me.CUST_NM & ""
[red]'can't assign value to object[/red]
End If
' If KPI Date
If Nz(Me.KPI_YR_MO) <> "" Then
'Add it to the predicate - exact match
strWhere = strWhere & " AND " & "KPI_YR_MO = " & Me.KPI_YR_MO & ""
[red]'SQL error[/red]
End If
' If Country
If Not IsNull(Me.WELL_CNTRY_NM) Then
'Create Predicate
strWhere = strWhere & " AND " & "WELL_CNTRY_NM = " & Me.WELL_CNTRY_NM & ""
[red]'Parameter Input box pops up[/red]
End If
' If Region
If Not IsNull(Me.G_RGN_NM) Then
' 'Create Predicate
strWhere = strWhere & " AND " & "G_RGN_NM = " & Me.G_RGN_NM & ""
[red]'Parameter Input box pops up[/red]
End If
' If Practice
If Not IsNull(Me.Practice) Then
'Create Predicate
strWhere = strWhere & " AND " & "Practice = " & Me.Practice & ""
[red]'Parameter Input box pops up[/red]
End If
If strError <> "" Then
MsgBox strError
Else
'DoCmd.OpenForm "Browse Products", acFormDS, , strWhere, acFormEdit, acWindowNormal
If Not Me.FormFooter.Visible Then
Me.FormFooter.Visible = True
DoCmd.MoveSize Height:=Me.WindowHeight + Me.FormFooter.Height
End If
Me.Browse_All_Products.Form.Filter = strWhere
Me.Browse_All_Products.Form.FilterOn = True
End If
End Sub
Thanks
gogirl