R
Renee
I am trying to have a specific form to be used as a quick search but i am
having a difficult time & I just give up. Anyone pls help me get this form
going. Thx.
My Formula is as followed on the event:
Private Sub Ctl_Search_Click()
Const cInvalidDateError As String = "You have entered an invalid date."
Dim strWhere As String
Dim strError As String
strWhere = "1=1"
' If Primary Code
If Nz(Me.Primary_Code) <> "" Then
'Add it to the predicate - exact match
strWhere = strWhere & " AND " & "HPG Members Overview.Primary Code =
" & Me.Primary_Code & ""
End If
' If Facility
If Nz(Me.Facility) <> "" Then
'Add it to the predicate - match on leading characters
strWhere = strWhere & " AND " & "HPG Members Overview.Facility Like
" * " & Me.Facility & " * ""
End If
' If City
If Nz(Me.City) <> "" Then
'Add it to the predicate - exact match
strWhere = strWhere & " AND " & "HPG Members Overview.City = """ &
Me.City & """"
End If
' If State
If Nz(Me.State) <> "" Then
'Add it to the predicate - exact match
strWhere = strWhere & " AND " & "HPG Members Overview.State = """ &
Me.State & """"
End If
' If MM Name
If Nz(Me.MM_Name) <> "" Then
'Add it to the predicate - match on leading characters
strWhere = strWhere & " AND " & "HPG Members Overview.MM Name Like "
* " & Me.MM_Name & " * ""
End If
' If Agent Contact Name
If Nz(Me.Agent_Contact_Name) <> "" Then
'Add it to the predicate - exact match
strWhere = strWhere & " AND " & "HPG Members Overview.Agent Contact
Name = '" & Me.Agent_Contact_Name & "'"
End If
' If Date of Contact
If IsDate(Me.Date_of_Contact) Then
' Add it to the predicate - exact
strWhere = strWhere & " AND " & "HPG Members Overview.Date of
Contact >= " & GetDateFilter(Me.Date_of_Contact)
ElseIf Nz(Me.Date_of_Contact) <> "" Then
strError = cInvalidDateError
End If
If strError <> "" Then
MsgBox strError
Else
'DoCmd.OpenForm ".frmBrowseMembers", acFormDS, , strWhere,
acFormEdit, acWindowNormal
If Not Me.FormFooter.Visible Then
Me.FormFooter.Visible = True
DoCmd.MoveSize Height:=Me.WindowHeight + Me.FormFooter.Height
End If
(The lines below are highlighted yellow)
Me.Browse_Members.Form.Filter = strWhere
Me.Browse_Members.Form.FilterOn = True
End If
End Sub
having a difficult time & I just give up. Anyone pls help me get this form
going. Thx.
My Formula is as followed on the event:
Private Sub Ctl_Search_Click()
Const cInvalidDateError As String = "You have entered an invalid date."
Dim strWhere As String
Dim strError As String
strWhere = "1=1"
' If Primary Code
If Nz(Me.Primary_Code) <> "" Then
'Add it to the predicate - exact match
strWhere = strWhere & " AND " & "HPG Members Overview.Primary Code =
" & Me.Primary_Code & ""
End If
' If Facility
If Nz(Me.Facility) <> "" Then
'Add it to the predicate - match on leading characters
strWhere = strWhere & " AND " & "HPG Members Overview.Facility Like
" * " & Me.Facility & " * ""
End If
' If City
If Nz(Me.City) <> "" Then
'Add it to the predicate - exact match
strWhere = strWhere & " AND " & "HPG Members Overview.City = """ &
Me.City & """"
End If
' If State
If Nz(Me.State) <> "" Then
'Add it to the predicate - exact match
strWhere = strWhere & " AND " & "HPG Members Overview.State = """ &
Me.State & """"
End If
' If MM Name
If Nz(Me.MM_Name) <> "" Then
'Add it to the predicate - match on leading characters
strWhere = strWhere & " AND " & "HPG Members Overview.MM Name Like "
* " & Me.MM_Name & " * ""
End If
' If Agent Contact Name
If Nz(Me.Agent_Contact_Name) <> "" Then
'Add it to the predicate - exact match
strWhere = strWhere & " AND " & "HPG Members Overview.Agent Contact
Name = '" & Me.Agent_Contact_Name & "'"
End If
' If Date of Contact
If IsDate(Me.Date_of_Contact) Then
' Add it to the predicate - exact
strWhere = strWhere & " AND " & "HPG Members Overview.Date of
Contact >= " & GetDateFilter(Me.Date_of_Contact)
ElseIf Nz(Me.Date_of_Contact) <> "" Then
strError = cInvalidDateError
End If
If strError <> "" Then
MsgBox strError
Else
'DoCmd.OpenForm ".frmBrowseMembers", acFormDS, , strWhere,
acFormEdit, acWindowNormal
If Not Me.FormFooter.Visible Then
Me.FormFooter.Visible = True
DoCmd.MoveSize Height:=Me.WindowHeight + Me.FormFooter.Height
End If
(The lines below are highlighted yellow)
Me.Browse_Members.Form.Filter = strWhere
Me.Browse_Members.Form.FilterOn = True
End If
End Sub