Adding a new record

chuckgoss

Registered User.
Local time
Today, 16:22
Joined
Mar 26, 2001
Messages
44
Hi all...

I'm trying to add a new record to a table that is not the record source for my main form. In fact, the Main form is displaying only the results of queries. In the past on other projects, I have been able to use the following method:

Dim db As Database
Dim rst1 As Recordset
Set db = CurrentDb
Set rst1 = db.OpenRecordset("tblwhatever")
rst1.AddNew
.....etc.

With this project, however, when I begin to key in the first line 'Dim db As Database', the word Database doesn't appear. My only options are:
DataAccessPage
DataAccessPages
DataTypeEnum
Date
DefaultWebOptions
...etc.

The first question is why don't I have the option to choose Database?

and

Secondly, is there some other way I might achieve adding a new record to my table?

Thanks in advance,

Chuck
 
In answer to your first question, while you are in your code window, select Tools then References and make sure you have referenced the Microsoft DAO Object Library. To answer your second question, no I don't think there is a better way to programmatically add a record to a table than by using a recordset.
 
CharityG!

I did as you said and indeed the library was NOT checked off!

Now it is, and I have 'Database' once again!

Thank you very much!

Chuck
 

Users who are viewing this thread

Back
Top Bottom