»
 

Go Back   ResellerRatings Store Ratings > ResellerRatings Forums > Tech Support

Reply
 
LinkBack Thread Tools Display Modes
Old 06-13-2003, 07:14 AM   #1 (permalink)
Registered User
 
Join Date: Mar 2003
Posts: 103
Marvinator is on a distinguished road
Acces Query Trouble

i'm in the middle of a database and need some help with Queries. I have a field that is a DATE field, and I want to be able to write a query that will pull out those records by MONTH by inputing the month in question. When I click on the Query, I want there to be an Input where I put in the 1 or 2 digits representing the month and then hit [enter] to bring up the list.

I've got the input sytax: Like [Type Month] - but this will not pull out just the month.

I've tried using wild cards, but it still gives me sytax errors. how would you write this query?

__________________
<img src=http://delta-laydee.com/marvs/marv.gif>

Last edited by Marvinator; 06-13-2003 at 07:18 AM.
Marvinator is offline   Reply With Quote
Old 06-13-2003, 07:17 AM   #2 (permalink)
Registered User
 
Join Date: Oct 2001
Location: TOO close to Wash DC
Posts: 7,956
vass0922 is on a distinguished road
use DATEPART function

Extract part of existing date values using a calculated field
In query Design view, create a query. Add the tables whose records you want to use.


Use the DatePart function in an expression in an empty cell in the Field row in the query design grid.
The syntax for this function is:

DatePart(datepart,date)

The datepart argument is the abbreviation for the part of the date you want returned. Examples are "yyyy" for a four-digit year and "q" for a calendar quarter. The date argument is either a field name with the Date/Time data type or a literal date such as "7-Nov-93".

The following table lists examples of expressions that apply the DatePart function to the OrderDate field from the Orders table. If the value in
OrderDate is
This expression
Returns
3-Jun-93 DatePart("m",[OrderDate]) 6 (month of year)
28-Mar-92 DatePart("yyyy",[OrderDate]) 1992 (four-digit number of year)

__________________
<< Insert exceedingly large and overly verbose message of how 1337 you are here including full specs of every vehicle you've ever driven and PC you've owned >>
vass0922 is offline   Reply With Quote
Old 06-13-2003, 07:21 AM   #3 (permalink)
Registered User
 
Join Date: Mar 2003
Posts: 103
Marvinator is on a distinguished road
This makes sense, however I want to be able to input WHICH month I am looking up. I want to call up a list of all items brought in during themonth of (example) June. so, when I click the Query, it should ask me for the month.

does this make sense?
__________________
<img src=http://delta-laydee.com/marvs/marv.gif>
Marvinator is offline   Reply With Quote
Old 06-13-2003, 07:24 AM   #4 (permalink)
Registered User
 
Join Date: Oct 2001
Location: TOO close to Wash DC
Posts: 7,956
vass0922 is on a distinguished road
Yes you'll have to create a form, then in the criteria reference that form...

its something like

Criteria: DATEPART("m", [ColumnName]) = formname1!controlname
or something like that, you may have to look up the exact syntax
__________________
<< Insert exceedingly large and overly verbose message of how 1337 you are here including full specs of every vehicle you've ever driven and PC you've owned >>
vass0922 is offline   Reply With Quote
Old 06-13-2003, 07:37 AM   #5 (permalink)
Registered User
 
Join Date: Mar 2003
Posts: 103
Marvinator is on a distinguished road
I've been playing with this for weeks. Syntax is not my strong suit. now, I can't seem to get this one thing to work, and at the same time, I'm getting way too many records that don't reall exist. i'm not sure why, but it's not working.
__________________
<img src=http://delta-laydee.com/marvs/marv.gif>
Marvinator is offline   Reply With Quote
Old 06-13-2003, 07:51 AM   #6 (permalink)
Registered User
 
Join Date: Oct 2001
Location: TOO close to Wash DC
Posts: 7,956
vass0922 is on a distinguished road
what is the criteria you have now?
cut and paste it into here.

Before you bother with the form, just hardcode a number for the month... once you get that working then bother with the form.
__________________
<< Insert exceedingly large and overly verbose message of how 1337 you are here including full specs of every vehicle you've ever driven and PC you've owned >>
vass0922 is offline   Reply With Quote
Old 06-13-2003, 08:01 AM   #7 (permalink)
Registered User
 
Join Date: Mar 2003
Posts: 103
Marvinator is on a distinguished road
Well, I don't need or want a form. I want a list, a data sheet.

for the field, I did as you stated.
Datepart("m",Tapes Received.Date) ;Tapes REceived is the name of the table.

for Criteria I have the following
Like [Type month]

Now this seems to work well, until I try to get more information than is in the Tapes Received Table. I also want the CITY and CONTACT LAST NAME from the main Contact Info Table. I have a relationship set up where the main part of both tables is the COUNTY. Now, when I try this out with just the information from the Tapes Received table, it seems to work. When i try to add in the City and Contact last name, it gives me every last name in the list connected to the only two counties in the Tapes Recieved Table.
__________________
<img src=http://delta-laydee.com/marvs/marv.gif>
Marvinator is offline   Reply With Quote
Old 06-13-2003, 08:17 AM   #8 (permalink)
Registered User
 
Join Date: Oct 2001
Location: TOO close to Wash DC
Posts: 7,956
vass0922 is on a distinguished road
You can't have spaces in table names or column names ... ALWAYS put the names in [brackets] if they have spaces

It sounds like you have a bad join that isn't valid.

Are you saying you join a contacts table and a "tapes received" table ... on a county?!?!
So you're saying there will never be more than one contact in one county?


Quote:
so, when I click the Query, it should ask me for the month.
If you want this functionality you will need a small form TMK
__________________
<< Insert exceedingly large and overly verbose message of how 1337 you are here including full specs of every vehicle you've ever driven and PC you've owned >>
vass0922 is offline   Reply With Quote
Reply




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Most Active Discussions

Recent Discussions

All times are GMT -6. The time now is 09:02 PM.