Microsoft Access Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMicrosoft Access Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
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  
Old September 27th, 2002, 08:56 PM
Kiwi Kiwi is offline
Guru-in-training
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2002
Location: Not where I want to be...yet!
Posts: 38 Kiwi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
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.

Reply With Quote
  #2  
Old September 30th, 2002, 06:25 PM
aspnewbie aspnewbie is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: The Great White North
Posts: 361 aspnewbie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 58 m 50 sec
Reputation Power: 7
Send a message via MSN to aspnewbie
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.

Reply With Quote
  #3  
Old October 19th, 2002, 02:37 PM
aspnewbie aspnewbie is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: The Great White North
Posts: 361 aspnewbie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 58 m 50 sec
Reputation Power: 7
Send a message via MSN to aspnewbie
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.

Reply With Quote
  #4  
Old November 11th, 2002, 01:22 AM
Siiiiip Siiiiip is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Location: Indonesia
Posts: 1 Siiiiip User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thumbs up Use "#"

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#"

Reply With Quote
  #5  
Old December 3rd, 2002, 08:00 PM
dgibson dgibson is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2002
Location: Urbana, MD, USA
Posts: 66 dgibson User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
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.

Reply With Quote
  #6  
Old February 23rd, 2004, 04:47 PM
scsandur scsandur is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 1 scsandur User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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?

Reply With Quote
  #7  
Old February 23rd, 2004, 09:25 PM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 6 m 11 sec
Reputation Power: 8
Send a message via ICQ to stumpy Send a message via MSN to stumpy
Remove the "AS Expr1" from the end (WHERE statement) - this is only for fields listed in the SELECT list.
__________________
DevArticles Moderator
BlueSix - Web Development and Consulting

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMicrosoft Access Development > MS Access 2000 parameter queries


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway