Using a Inputbox in a filter for a report (1 Viewer)

DanG

Registered User.
Local time
Today, 07:15
Joined
Nov 4, 2004
Messages
477
I want to have the user supply the date when an inputbox appears when the report is run.
Here is what I have:

Code:
Private Sub Report_Open(Cancel As Integer)

Dim inputdate As Date
inputdate = InputBox("Enter Date Criteria")

Me.Filter = "date >='& # inputdate # '"
Me.FilterOn = True
End Sub

I am close but not quite there.
Would love help....Thank you
 

boblarson

Smeghead
Local time
Today, 07:15
Joined
Jan 12, 2001
Messages
32,059
use

Code:
Me.Filter = "date >='#" &  inputdate & "#'"

instead
 

DanG

Registered User.
Local time
Today, 07:15
Joined
Nov 4, 2004
Messages
477
Much closer thank you!
I now get an error "Data Type Mismatch in Criteria Expression"

My table, query and report all have the date field setup as a date/time data type.

And in the "Properties" here is how the variable getting passed to the "Filter" reads: "date >='#8/3/2006#'

Too strange.
Thanks for the syntax help, I never quite understand how to use quotaion marks.
 

DanG

Registered User.
Local time
Today, 07:15
Joined
Nov 4, 2004
Messages
477
Got it!!!

Code:
[B]'[/B]#" &  inputdate & "#[B]'[/B]"

Since I am using the # I do not need the single '

I'm learning while I'm earning...again thank you very much.
 

Users who are viewing this thread

Top Bottom