Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pass a value to a Pass-Through Query? 2

Status
Not open for further replies.

CptCrusty1

Programmer
Feb 17, 2005
216
US
I have a passthrough query that requires a date time setup to be passed to it, i.e.:

Start time = 07/08/2005 00:00:00 AM
End Time = 07/08/2005 12:59:59 PM

Without opening the query every time I want to run it, and changing the dates, is there a way to pass a time variable to the query after prompting the user?

I live to work and I work to live.
 
In the DAO library there is a QueryDef.

In Help lookup QueryDef and the associated Parameter Collection. The Help file has an example showing exactly what you are trying to do.
 
To expand cmmrfrds' suggestion, try code like:

Code:
Dim strSQL as String
strSQL = "SELECT * FROM SALES WHERE SaleDate Between '" & _
  Me.txtStartDate & "' AND '" & Me.txtEndDate & "'"
Currentdb.QueryDefs("qsptMyPassthrough").SQL = strSQL

If you can't figure this out, don't be so shy about sharing your SQL of the pass-through as well as the source of your start and end time values.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
As Homer Simpson would say.... "DOH!!!"

Dhookom... I completely, I mean absolutley totaly, (did I mention completely) forgot that I could pass a variable to the query if its in code. (Switch to California accent) Thats like totally knuckle-brained of me dude!!

You've helped me before... so again, thanks.

Crusty.

I live to work and I work to live.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top