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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using controls as parameters in pass-through queries

Status
Not open for further replies.

SadOldGoth

Programmer
May 21, 2002
42
GB
Hi Folks,

Can anyone give me an example of how to use the values of a control on a form as a parameter in an SQL pass-through query?

I'm using access 2k and SQL-2000.

Thanks,

Jes
 
There are no example's 'cos it can't be done. Pass-Through queries do just that. Pass the query to the server without any processing at the client end.
What you will need to do is create a piece of code that changes the sql of your query as required.
I'm in the middle of doing this at the minute, so:

Sub fqptOracle(strEmployeeNumber as String)
dim qdf as DAO.QueryDef
dim strSQL as string

strSQL="SELECT * FROM HR.PER_PEOPLE_F WHERE Employee_ID='" & strEmployeeNumber & "'"
set qdf=Currentdb.Querydefs("qptOracle")
qdf.SQL=strSQL
set qdf=Nothing
docmd.OpenQuery "qptOracle",acViewNormal,acReadOnly
End Sub

My code just opens the query so the user can see the data. You may want to do something else like change a recordset to the query or whatever.

hth

Ben

PS Love the nick!!

----------------------------------------------
Ben O'Hara

"Where are all the stupid people from...
...And how'd they get so dumb?"
NoFX-The Decline
----------------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top