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!

Not in List

Status
Not open for further replies.

tizwaz

Technical User
Aug 8, 2002
437
0
0
GB
I'm having problems trying to set the Not In List event of my combo box. It halts on the line DimdbsAssets as Database with the error msg compile error user-defined type not defined. Does anyone know what I need to do to correct this?

Private Sub userName_NotInList(NewData As String, Response As Integer)
' Ask the user whether to add a value to the list
Dim strMessage As String
Dim dbsAssets As Database
Dim rstUsers As Recordset

strMessage = "Are you sure you want to add '"" & NewData & -" 'to the list of Users?"
If Confirm(strMessage) Then
'open the tbl_Users table and add the NewData value.
Set dbsAssets = CurrentDb()
Set rstUsers = dbsAssets.OpenRecordset("tbl_Users")
rstUsers.AddNew
rstUsers!tbl_Users = NewData
rstUsers.Update
Response = acDataErrAdded 'requery the list
Else
Response = acDataErrDisplay 'display the error
End If
End Sub
 
Give me a call and I can give the code and walk you through this. 703-248-7842 or rsmith@litsllc.com
 
Sounds like you are using Access 2000 or better and have both the ADO and DAO object models enabled. Using a fully qualified datatype should work. DAO.Database and DAO.recordset are fully qualified. Good luck.
 
Thanks but I'm not sure what you mean. What would I need to change? I am using Access 2000.
 
Change...
Dim dbsAssets As Database
Dim rstUsers As Recordset

to...

Dim dbsAssets As DAO.Database
Dim rstUsers As DAO.Recordset
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top