Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Docmd.ApplyFilter does not work

Status
Not open for further replies.

jofet

MIS
Sep 3, 1999
32
PH
i have this form to open with an underlying table, i need to filter out the record before it shows but it does not work.


Private Sub Form_Open(Cancel As Integer)
Dim Mystr As String
On Error GoTo Error

Mystr = Left(Format(Now(), "dddd"), 3)
If Mystr = "Mon" Then
DoCmd.ApplyFilter , [Days] Like "*2*"
End If
Exit Sub
Error:
MsgBox Err.Description

End Sub


i need to filter out the [Days] field with any number containing "2", but the ApplyFilter does not work, it shows "filtered" on the record navigation but it still show all the records in the table why is that? please help.
 
The whole second argument to the ApplyFilter method should be a string expression. Also, the criteria expression with the Like operator should be enclosed in single quotes:

Code:
DoCmd.ApplyFilter , "[Days] Like '*2*'"

I hope that was helpful,
/gny

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top