DAO table structure only

meboz

Registered User.
Local time
Tomorrow, 00:47
Joined
Aug 16, 2004
Messages
71
HI all,

I want to open a DAO recordset for the sole purpose of appending new records (.addnew).

Thus, I do not wish to return any records (im a bit of a network conservationist), since I do not need them.

My current method is to use an SQL statement with a WHERE clause on the primary key with a value that is not in, and will never be in the primary key.

I dont like this method because If i looked at my programming I would think I was a moron for sending a '0' as criteria against an AutoNumber field

Can someone suggest a better way to return a DAO recordset for the sole purpose of appending records?

Thanks...
 
How about:

Set rs = db.OpenRecordset("TableName", dbOpenDynaset, dbAppendOnly)
 
Code:
Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("tblName", dbOpenDynaset, dbAppendOnly)    'you may also use the old constant DB_APPENDONLY or 8

With rs
    .AddNew
        ![Column Name1] = "Value of this field"
        ![Column Name2] = "Some other data"
        ![Column Name3] = Date()
        '...keep adding data to your record as needed...
    .Update
End With

Hope this helps,
Modest
 
Last edited:
modest said:
Set rs = CurrentDb.OpenRecordset("tblName", dbOpenDynaset)

Modest, I think you'll find that the method you used will return all records in the table, which is not what the OP was after. Using dbAppendOnly will prevent that.
 
Ahhh I missed what he was trying to say. I've now edited my post to meet the correction. Thanks for pointing it out.
 
Very nice, thanks for the reply
 

Users who are viewing this thread

Back
Top Bottom