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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I just cant fathom this 2 field filter out 2

Status
Not open for further replies.

JamesBBB

Technical User
Nov 2, 2005
74
GB
hi all,

I have read trough the articles inthe forum re multiple filters and cannot seem to see what Im doing wrong, its so frustrating, Ive been staring at it for over an hour.

basically I need to filter on a STAFF ID and a LEAVE TYPE, and Im suing the following code:-

ab = Me![Staff Number]
ac = Me![Leave Type]
DoCmd.ApplyFilter , "[Staff Number]='" & ab & "' And [Leave Type] = '" & ac & "'"
Me.FilterOn = True

when I run this I get a "The Apply filter was Cancelled. Could any please have a look at the above code and advise me what Im doing wrong.

many thanks

James
 
You seem to be mixing two ideas:

[tt]Me.Filter = "[Staff Number]='" & ab & "' And [Leave Type] = '" & ac & "'"[/tt]


(You won't have to sue the code :)


 
Also, if [Staff Number] is a number data type, you wouldn't put quotes around it.

 
Hi Remou and Joeatwork

Thanks for that, at least I now know what the code looks like although it was still failing and I just did not know what else to do.

I then checked my thread again this evening and read Joeatwork's comment about the numbers and the quotes and "Voila" it works. I am one very happy chappie tonight.

Many thanks guys, your help was fantastic.

Cheers

james
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top