Can't Find Query Error

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

Guest

Can someone see my error in the following code. I get an "Access can't see query error on the OpenQuery command.
The query is built in the proper place, however.

Function RunQuery()
Dim wrkJet As Workspace, dbBackEnd As Database, qd As QueryDef, strPath As String, strFileNme As String
Dim sqlString As String

'DoCmd.SetWarnings False

strPath = "H:\Development\FolderName\"
strFileNme = "File_BE.mdb"

sqlString = "some sql to make table query string "

Set wrkJet = CreateWorkspace("", "admin", "", dbUseJet)
Set dbBackEnd = wrkJet.OpenDatabase(strPath & strFileNme)

With dbBackEnd
Set qd = .CreateQueryDef("qryQueryName", sqlString)
DoCmd.OpenQuery "qryQueryName", acViewNormal, acEdit
.QueryDefs.Delete qd.Name
End With

'DoCmd.SetWarnings True
End Function

Thanks for the Help
Rosco
 
Try adding:

DoEvents

once or twice after the statement "Set qd ..." and before the
"DoCmd.OpenQuery ..."

--
HTH
Van T. Dinh
MVP (Access)


Rosco said:
Can someone see my error in the following code. I get an "Access can't see
query error on the OpenQuery command.
The query is built in the proper place, however.

Function RunQuery()
Dim wrkJet As Workspace, dbBackEnd As Database, qd As QueryDef, strPath
As String, strFileNme As String
 
No soap, Van. Still getting the "Can't find the object" error
Thanks for trying, any other suggestions
Rosc
 
Just realised that you created the query in the Back-End and the
DoCmd.OpenQuery will only look for the Query in the Front-End.
 
So, how can I run a query on the back end, from the front end. I am trying to update a table on the back end as part of a start up routine. The query grabs data from an AS400 table, and I do not want to give the users direct access to the AS400 table in question
Thanks
 
Back
Top