Filter report on text and date drop down lists

T. McConnell

Registered User.
Local time
Today, 01:33
Joined
Jun 21, 2019
Messages
63
Greetings all,
Been a while since I have posted on here, but I have another issue with filtering a report. I have 2 drop downs to filter a report on, one is to select a date, the other is to select a truck number. I can get the truck number one (which is short text) to finally work, but when I try to get the date to work with the truck selection I get an error saying error type mismatch. I know it has something to do with the formatting of the code on the date piece, but I am having a huge brain fart on it. If someone could take a look at the code below and let me know what you see wrong.

Report name is TruckLog, Truck ID is the field on the Form pulling from, Select Truck is drop down 1 on the form, DeliveryDate is the date field being pulled from the form, and SelectDate is the 2nd drop down. Any help is greatly appreciated.

Code:
DoCmd.OpenReport "TruckLog", acPreview, , "[TruckID]='" & Me![SelectTruck] & "' AND [DeliveryDate]='" & Me![SelectDate] & "'"
 
Dates are surrounded with # and need to be in mm/dd/yyyy or yyyy-mm-dd format.
Put the criteria into a string variable, then you can debug.print it until correct.
 

Users who are viewing this thread

Back
Top Bottom