I have a form that is filtered to only show the records aligned to the user when they log in. ON that same form I have a search box with the following code I found
Code:
Private Sub CmdFilter_Click()
Dim strWhere As String
Dim lngLen As Long
Const conJetDate = "\#mm\/dd\/yyyy\#"
If Not IsNull(Me.AccountName) Then
strWhere = strWhere & "([Account] Like ""*" & Me.AccountName & "*"") AND "
End If
lngLen = Len(strWhere) - 5
If lngLen <= 0 Then
MsgBox "No criteria entered", vbInformation, "Null Search."
Else
strWhere = Left$(strWhere, lngLen)
Debug.Print strWhere
Me.Filter = strWhere
Me.FilterOn = True
End If
End Sub
The issue is when I execute the search it returns all the records that match and not just the ones that belong to the logged in user. I am assuming I need to add a second criteria to the strWhere to limit the results to the current user to the following second of the search code
Code:
strWhere = strWhere & "([Account] Like ""*" & Me.AccountName & "*"") AND "
but I have been unable to get it to work.
The main form is filtered by looking at the value in the login form
Code:
Private Sub Form_Open(Cancel As Integer)
Me.Filter = "[XeroxCanada_EmpNo] = '" & Forms!Logon_Form!cboUser.Column(0) & "'"""
RunCommand acCmdApplyFilterSort
End Sub
Any help would be appreciated as always.