Parameter Query with a Condition

  • Thread starter Thread starter Nick
  • Start date Start date
N

Nick

I am trying to create a query in Access which would pull
the items with a Date which are at least 30 Days less than
the Date I enter into my parameter query. Here is an
example of my SQL I used in my unsuccesful attempt.

SELECT TABLE1.PRODMONTH, TABLE1.COSTID, TABLE1.AMOUNT
FROM TABLE1 TABLE1
WHERE TABLE1.PRODMONTH < [Enter Prod Date] - 30

Can anyone lead me in the right direction or have any
suggested websites that might help me figure this out.

Thank you in advance for any help that can be provided.
 
If you need the parameter to be a specific datatype (as you do here, it must
be a date) then you need to add a Parameter Statement. This comes before
the SELECT statement like this:

PARAMETERS [Enter Prod Date] DateTime;
SELECT TABLE1.PRODMONTH, TABLE1.COSTID, TABLE1.AMOUNT
FROM TABLE1 TABLE1
WHERE TABLE1.PRODMONTH < [Enter Prod Date] - 30

(The Parameters statement MUST end with a semicolon.)

You can do this in the Query Builder by going to Query>Parameters on the
menubar.
 
Nick,

Do you really have TABLE1 twice in the FROM clause, or was this a typo
in your post?
What is the data in your PRODMONTH field? Is it a Date/Time data type?
 
Back
Top