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

Invalid Qualifier Error

Status
Not open for further replies.

FrancieFL

Technical User
Mar 3, 2003
20
US
I am creating an unbound form that receives initials and uses them to determine what the next available key should be for given initials. When I run my test and select the add button I receive an "Invalid Qualifier" error on the "Set rst" line. VSBasic highlights the "dbs" right after the equal sign. The database I am using is an Access database I created. Am I using an incorrect way of selecting rows from the database?

Thanks for any help you may be able to give me.
Francie

Here is my VSBasic code. I have noted the line in error, below.

Public Sub GetNumber_Click()

Dim dbs As String
Dim rst As DAO.Recordset
Dim StrSQL As String

StrSQL = "SELECT Left(Max([Customer_Code]),2) AS ['Initials'], " & _
"Right(Max([Customer_Code]),6)+1 AS ['LastCodeUsed'] " & _
"FROM [ClientMaster] " & _
"WHERE (Left([Customer_Code],2)=Me![Initials_In]); "
Debug.Print "SQL="; StrSQLS
' Set dbs = CurrentDb
dbs = "ClientMaster"
Set rst = dbs.OpenRecordset(StrSQL) <-- THIS IS THE ERROR LINE

Debug.Print &quot;Dbs=&quot;; dbs
Debug.Print &quot;Rst=&quot;; rst

' rst.Open StrSQL

' DoCmd.OpenQuery &quot;LastClientCodeUsed&quot;

' NewClientCode = FrmName![Initials_In] & &quot;00000&quot; & rst.[LastCodeUsed]
NewClientCode = FrmName![Initials_In] & &quot;00000&quot;

' DoCmd.OpenForm (&quot;NewClientEntry&quot;)

End Sub
 
Dim dbs as String
should be
Dim dbs as DAO.Database

That should fix it.

Paul
 
Thank you both so very much. That got me past that problem.

Francie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top