Hi all
This is the first time I am writing on this forum. I am trying to refer to a query in my vba code but it does not work. Do I have to create a connection even though the query is in the current database. Any help in this regard will be appreciated.
If you have a variable mstrQuery and fill it with the query name this would work.
CurrentDb.Execute mstrQuery -------------------------------------
scking@arinc.com
Try to resolve problems independently
Then seek help among peers or experts
But TEST recommended solutions
-------------------------------------
Sorry, but I gave you the execute for running the action query. The following will run a select query. I'm doing it with a variable but if you replace the mstrQuery with the "YourQueryName" for the name of your query that would work also.
'To open as a recordset
Dim rstIN As DAO.Recordst
Set rstIN = CurrentDb.OpenRecordset(mstrQuery)
If rstIN.RecordCount <> 0 Then
' proceed
Else
Exit Sub
End If
-------------------------------------
scking@arinc.com
Try to resolve problems independently
Then seek help among peers or experts
But TEST recommended solutions
-------------------------------------
hi scking..
One more thing. I want to populate my form with records in the query and it does not allow me to navigate the records. My code is as follows:
Dim rstIN As DAO.Recordset
Set rstIN = CurrentDb.OpenRecordset("test"
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.