Run-time error 2501 (1 Viewer)

ansentry

Access amateur
Local time
Tomorrow, 08:46
Joined
Jun 1, 2003
Messages
995
I have a combo box on a form with the following code in the after upate;

Code

Private Sub cmboFilter_AfterUpdate()
If Me![cmboFilter] = "<All>" Then
DoCmd.ShowAllRecords
Else
DoCmd.ApplyFilter , "[RegistrationNumber] = '" & Me![cmboFilter] & "'"
End If
End Sub



Data Source

SELECT DISTINCT RegistrationNumber FROM Qry_RegFilter UNION SELECT "<All>" FROM Qry_RegFilter;

This works fine, BUT the following does not and the only difference is that the look up field OutDate is date format.

Code
Private Sub cmboFilter_AfterUpdate()
If Me![cmboFilter] = "<All>" Then
DoCmd.ShowAllRecords
Else
DoCmd.ApplyFilter , "[OutDate] = '" & Me![cmboFilter] & "'"


End If
End Sub

Source

SELECT DISTINCT OutDate FROM Qry_OutDateFilter UNION SELECT "<All>" FROM Qry_OutDateFilter;


Thank you in advance
 
R

Rich

Guest
DoCmd.ApplyFilter , "[OutDate] = " & Me![cmboFilter]
just noticed your in Oz, so you'll probably have to use
DoCmd.ApplyFilter , "[OutDate] = " & Format(Me![cmboFilter],"mm/dd/yyyy")
 
Last edited:

ansentry

Access amateur
Local time
Tomorrow, 08:46
Joined
Jun 1, 2003
Messages
995
Rich,

Thank you for your reply, yes I am in Oz but we still use

dd/mm/yy (7th June 2003)

Sorry to say I still am unable to get it to work.

I have attached a sample db, as you will see the "Driver" filter works fine. I have put your code in (at least it does not give an error) but it appears to do nothing.

Regards,


:rolleyes:
 
R

Rich

Guest
Outside of the US you have to format the dates in US style to return the correct records when filtering or returning dates from strings, try this
 
Last edited:

ansentry

Access amateur
Local time
Tomorrow, 08:46
Joined
Jun 1, 2003
Messages
995
Rich,

I have tried both ways dd/mm/yyyy and mm/dd/yyyy in the one you returned and you are right only mm/dd/yyyy works .

That will make no difference to the user, so thank you for your help it is appreciated.

Regards,




:p :p :p :p
 

Users who are viewing this thread

Top Bottom