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

User Defined Type not Defined Error

Status
Not open for further replies.

FrancieFL

Technical User
Mar 3, 2003
20
0
0
US
I am receiving the User Deined Type error on the "Dim dbs" statement. What I am trying to do is select the next value of "Last Code Used" so I can generate the next key.

Am I working with DAO incorrectly?

Thanks,
Francie

Here's the code:

Public Sub GetNumber_Click()

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

Set FrmName = Forms![GetInitials]

StrSQL = "SELECT Left(Max([Customer_Code]),2) AS ['Initials'], " & _
"Right(Max([Customer_Code]),6)+1 AS ['LastCodeUsed'] " & _
"FROM [Clientr Master] " & _
"WHERE (Left([Customer_Code],2)=FrmName![Initials_In]); "

Set dbs = CurrentDb
Set rst = dbs.OpenRecordset(StrSQL, dbOpenDynaset)

rst.Open StrSQL

' DoCmd.OpenQuery "LastClientCodeUsed"

NewClientCode = FrmName![Initials_In] & "00000" & rst.[LastCodeUsed]

End Sub
 
Looks like you will have to check your refrences via tools / refrences and incl. the ref to microsoft dao 3.x

Rgds Herman
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top