|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
MS Access 2000 parameter queries
Hi guys,
Can anyone help me with a problem I'm having running a parameter query in Access 2000 ? I have a table that has a date/time field that I need to query, based on user input. I want the user to be able to select a date and retrieve all the items received on that day. Problem is if I use the notation =[Date?] in the criteria box in the query design view, it returns no results, even though there are records that should be returned. What is the correct syntax I should be using ? If anyone can point me in the direction of a tutorial I'd be grateful. Thanks. |
|
#2
|
|||
|
|||
|
My experience with Parameter queries in Access is that they can be pretty exacting. You have to match the exact wording/format to get the results you want, unless you truncate and use "Like"
Have you tried Code:
LIKE "*" & [Enter the date] & "*" Last edited by aspnewbie : September 30th, 2002 at 06:36 PM. |
|
#3
|
|||
|
|||
|
Realized I may have given you the wrong advice. That query works well for text strings. For dates, the =[Date?] did work for me (access 2000). However, I note that I had to ensure that all my date entries were formatted exactly the same. A couple of entries had date and time in them as opposed to just short date format and that threw off the parameterized query. Good luck.
|
|
#4
|
|||
|
|||
|
you must use "#" at the begin and end of date string (the date must be formatted as mm/dd/yyyy).
Example : "select * from TableName where DateField = #12/31/2002#" |
|
#5
|
|||
|
|||
|
Saw a similar problem in Cold Fusion recently. The date "looked" to be the same format as the one in Access, but in fact, yielded no results until #CreateODBCDate()# was wrapped around it. In effect, the date in Access looked like a formatted date of 12/12/02, but in fact was being returned as an ODBC date object and comparisons were failing as a result.
|
|
#6
|
|||
|
|||
|
Some more help needed
I have a query tat works fine for like queries in MS Access
SELECT ClassAssigned.* FROM ClassAssigned WHERE B_Time Like "*" & [Enter Begin Time] & "*"; Here the user is prompted wiht a dialog box Now for date query SELECT DateofCrash FROM Tcrash_Incident WHERE DateofCrash Between #1/1/2004# And #1/10/2004# also works fine, since it is hard coded Now i want the user to be prompted with date between query SELECT DateofCrash FROM Tcrash_Incident WHERE DateofCrash Between "#" & [Enter Begin Time] & "#" And "#" & [Enter End Time] & "#" AS Expr1; Now the above doesn't work, what am i doing wrong? |
|
#7
|
||||
|
||||
|
Remove the "AS Expr1" from the end (WHERE statement) - this is only for fields listed in the SELECT list.
|
![]() |
| Viewing: Dev Articles Community Forums > Databases > Microsoft Access Development > MS Access 2000 parameter queries |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|