DAO error

andyswinburne

Registered User.
Local time
Today, 11:23
Joined
Sep 29, 2003
Messages
22
Hi,

I am trying to use code to create a new record in a table, I have found code in a book and online help which looks as if it would work.

But I get an error at the first line:
Dim dbs as Database, rst as DAO.RecordSet

it doesn't recognise 'Database' and just says:

User-defined type not defined

why is this?

cheers

Andy
 
Access provides a quick code builder using the toolbox's command button

PHP:
Private Sub yourcontrol_Click()
On Error GoTo Err_yourcontrol_Click


    DoCmd.GoToRecord , , acNewRec

Exit_yourcontrol_Click:
    Exit Sub

Err_yourcontrol_Click:
    MsgBox Err.Description
    Resume Exit_yourcontrol_Click
    
End Sub
 
craw's code will work in a form. If that's the situation, then problem solved.

If you're trying to do something programatticaly with your data using DAO, then I'm guessing you're using Access 2000 or higher. You need to set a reference to DAO in the Visual Basic Editor. Go to Tools, References. Go down the list and look for Microsoft DAO 3.x and check it.
 
You wrote
<<
But I get an error at the first line:
Dim dbs as Database, rst as DAO.RecordSet

it doesn't recognise 'Database' and just says:

User-defined type not defined
>>

Dim dbs as DAO.Database, rst as DAO.Recordset

RichM
 

Users who are viewing this thread

Back
Top Bottom