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

Changing an update query through a module?

Status
Not open for further replies.

Mashieman9

Technical User
Jul 16, 2003
9
0
0
US
Is it possible to change an update query through a module? I have a variable in the module that I need to use in the query. If so, could someone help me out?

Thanks,
Nathan
 
You sure can!

lets see you update query and your code
 
I use DAO in a generic function.

Function ChangeSQL(pstrQuery As String,
pstrSQL as String) as String
Dim db as DAO.Database
Dim qd as DAO.QueryDef
Set db = CurrentDb
Set qd = db.QueryDefs(pstrQuery)
ChangeSQL = qd.SQL
qd.SQL = pstrSQL
Set qd = Nothing
Set db = Nothing
End Function


Duane
MS Access MVP
 
Where is the variable and the SQL String.

You need to concatenate the SQL String with you varaible value if that is a criteria.
 
If you are referring to my posting, I use the function like:

Dim strSQL as String
Dim strOldSQL as String
strSQL = "Select ... FROM... where...."
strOldSQL = ChangeSQL("qselMy",strSQL)


Duane
MS Access MVP
 
So far it makes sense, I just can't see how the code is referencing the query. The query's name is "UpdateStock".

Thanks again.

--
N.Hunt
 
And I was supposed to know that how? Try replace "qselMy" and strSQL with "UpdateStock" and your SQL.

Duane
MS Access MVP
 
Thanks for all the help... I feel kinda stupid, I found a much easier way to do it.

Thanks.

--
N.Hunt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top