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

MSQuery Date parameter

Status
Not open for further replies.

TheGus

Technical User
Jan 14, 2005
5
IE
I have created a query using MSQuery and I want the user to be able to enter a start date and an end date so that a range can be created. However, no moatter what format I use for the date in the input box, I keep getting an error that the format is wrong!

Here is the part of the query that does this:
Code:
AND (ENDDT Between '#' & ? & '#' And '#' & ? & '#') AND

Any ideas why this is failing?
 
That doesn't work either! I have tried every combination of the above but can get it to work.

Any other ideas
 
AND (ENDDT Between [Enter start date] And [Enter end date])

When prompted type the date like this: #1/15/2005#

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Slowed down by another lost connection ... sigh

Hmmm
The simple approach may to be to ask for each date separatly, test the date and then encapsulate for MS*Query
Code:
Dim StartDate as Date, EndDate as Date

StartDate = InputBox("Enter start date: ",,Date())

If IsDate(StartDate) then
  EndDate = InputBox("Enter start date: ",,Date())
  If Isdate(EndDate) Then
     ...AND (ENDDT Between "#" & StartDate & "#" And "#" & EndDate & "#") ...
  End If
End If

Richard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top