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

Opening a table in MS Access 2000

Status
Not open for further replies.

MrMajik

IS-IT--Management
Apr 2, 2002
267
0
0
I am having trouble opening a table to write data to it under a pushButton method. I keep getting a Microsoft Visual Basic error that says, "Compiler error: User-defined type not defined.".

The problem is coming from the first line in the code below (Dim dbs as database). I am using MS Access 2000. What am I doing wrong?

Dim dbs as database
Dim msrt as recordset
Dim myNumber as string
Set dbs as CurrentDB
Set msrt as dbs.openrecordset ("TestDB", dbOpenDynaset)
myNumber = "123456"
mrst.movefirst
mrst.edit
mrst.AddNew
mrst!TheNum.value = myNumber
mrst.Update
set mrst = nothing
 
Try replacing the "as" with "="
Set dbs as CurrentDB
Set msrt as dbs.openrecordset ("TestDB", dbOpenDynaset)

change to:
Set dbs = CurrentDB
Set msrt = dbs.openrecordset ("TestDB", dbOpenDynaset)
 
PhybrOptk; Thank you for the quick reply.
I tried putting in your code but the error message still appears. When the error message appears Micorsoft Visual Basic colors the "dbs as database" as the focus of the problem. Again, this is the first line of the code.

It is acting like it does not understand the word "database" because it is expecting it to be user-defined.

Any other thoughts...
 
Since you are in Access 2000 the default is ADO ojects. DAO objects should be prefixed with DAO.
DAO.Database

Also, check your reference library to see that the DAO reference library is checked.
 
cmmrfrds and PhybrOptk; That did it. This case is closed.

Thank you!

MrMajik
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top