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

References?

Status
Not open for further replies.

dutch62

Programmer
Dec 31, 2001
58
NL
Hi all,

(I'm from Holland, so if my English is poor, sorry :) )

Is it possible in Access 2000 to create a series of new records (let's say 50) without using the command
DoCmd.GoToRecord , , acNewRec ?

This method works, but it's not very elegant, because the user must wait until Access stops scrolling through the 50 new records in a form.

I think it is possible to use the Recordset object, but when I try this, Access keeps telling me that the types do not match. This is the code I use:

Private Sub butNewClick()
Dim dbs As Database, rst As Recordset

Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tblNew")

With rst
.AddNew
!naam = "Jan Koehoorn"
.Update
End With

rst.Close
dbs.Close
End Sub

In VBA, this is what I have in [Extra]->[References]
- Visual Basic for Applications
- Microsoft Access 9.0 Object Library
- OLE Automation
- Microsoft ActiveX Data Objects 2.7 Library
- Microsoft DAO 3.6 Object Library

Any help would be much appreciated.
"Dutch"
 
It doesn't match because Access thinks your recordset is ADODB.Recordset. In reality, it is DAO.Recordset.

So:
Private Sub butNewClick()
Dim rst As DAO.Recordset

Set rst = CurrentDb.OpenRecordset("tblNew")

With rst
.AddNew
!naam = "Jan Koehoorn"
.Update
End With

rst.Close
Set rst = Nothing 'a preference of mine [smile]
End Sub

You have to fully qualify the recordset if you use DAO model.

You have nice tulips there in Netherlands...
[pipe]
Daniel Vlas
Systems Consultant
danvlas@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top