VBA Query returning Error Number "0"

G

Guest

Realtively new to Access programming, so bear with me. I have a database on a
server with one linked table (through the Link table wizard). I am trying to
run a query using a parameter passed from a form. I am struggling to get it
to work, and even switched from ADO to DAO. The code is below. Any
suggestions appreciated.

'Defining the recordset and setting connection
Dim dbs As Database
Dim rs As DAO.Recordset
Dim strSQL As String

Set dbs = CurrentDb

'Define SQL string for the RS
strSQL = "Select tblNamesExtensions.[Manager], "
strSQL = strSQL & "tblNamesExtensions.[First Name], "
strSQL = strSQL & "tblNamesExtensions.[Last Name], "
strSQL = strSQL & "tblNamesExtensions.[Extension], "
strSQL = strSQL & "tblNamesExtensions.[VM Password] "
strSQL = strSQL & "From tblNamesExtensions "
strSQL = strSQL & "Where tblNamesExtensions.[Manager] = '" &
Me.Manager & "'" & ";"

Set rs = dbs.OpenRecordset(strSQL, dbOpenSnapshot)
 
A

Allen Browne

If you have an error handler in this VBA procedure, and it is returning
Error 0, you have forgotten to include the:
Exit Function
or
Exit Sub
above the error handler.

Consequently the error code executes, even though there is no error.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top