View Full Version : Add Records and Data with Loop?


Guy Rondeau
08-16-2000, 11:50 AM
Greetings:

I'm using Access97. I use text boxes on a form to display the records and data. I would like to add a button and use it's click event to add new records and data for those records. I was trying to use a loop something like this:

Private Sub AddNewRecords Click()
Option Compare DataBase
Option Explicit

Dim Count As Number
Dim Var1 As Number

Count = 0
'Each record has a number field called tag, get last tag number used
???Move to last record???
Var1 = Me.tag

'Add new records and data to the fields
Do until count = 150
???Add New Record???
Me.tag = Var1 + 1
Me.this = something
Me.that = something
Me.lots more fields = something etc
Var1 = me.tag
Count = Count + 1
Loop
End Sub

I don't know what code is needed to "Move to the Last Record" and "Add New Record". In help it talks about establishing record sets and updating but I don't know what this means or how it is done. Your help is appreciated.

Thanks

Jack Cowley
08-16-2000, 02:21 PM
I do not understand what you are trying to do, but to move to a new record you only need to use the command "DoCmd.GoToRecord, , acNewRec" in an On Click Event Procedure of a command button. And Access is designed to add one record at a time not a bunch of them and that is where I have lost you. Maybe a bit clear example of what you want to do will help someone to assist you in your quest.

HTH,
Jack