Passing a Date to a passthrough query

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

I know people have asked this before but please help an ancient ignoramous.

I have a pass through query to return records that match a date. This works
fine when the date is hard written in the SQL.

I need a method to change the hard written date in the SQL to one selected
by the user.

As I have read, but not fully understood, previous responses would you
please spell out how I do this. I don't know visual basic so would have to
use a macro to, I guess, open a Module and then run a function contained in
the module.

Thanks
 
*IF* you use the query to display the record in a form

then, in that form RecordSource property, place the SQL statement like:

SELECT ...list of fields...
FROM tableNameHere
WHERE dateField = FORMS!FormNameHoldingTheControl!ControlNameHere



where FormNameHoldingTheControl is another form, open, with a control
filled with the date you want use in the criteria.

A possible scenario is:

Open FormNameHoldingTheControl, let the user fill the control, and, on
a button click, open the first form, the one with the mentioned record
source. You can turn FormNameHoldingTheControl invisible at the button
click, and close it when you close the other form.




Note that I assumed the dateField values don't hold any time portion. If
they have a time portion, you may try some variation on the WHERE clause,
like:


WHERE dateField >= FORMS!FormNameHoldingTheControl!ControlNameHere AND
dateField <1+CDate(FORMS!FormNameHoldingTheControl!ControlNameHere )




Hoping it may help,
Vanderghast, Access MVP
 
Back
Top