- Place an Unbound Textbox in the Header Section of your Form.
- Name it NumberOfRecords.
- Place a Command Button in the Header of the Form.
- Name it CreateMutliRecords
Place this code behind the
Button:
Code:
Private Sub CreateMutliRecords_Click()
If Nz(Me.CartridgeType, "") = "" Then
MsgBox "You Must First Enter a Cartidge Type!"
Exit Sub
End If
If Nz(Me.NumberOfRecords, 0) <> 0 Then
varNumRecords = Me.NumberOfRecords
Else
MsgBox "You Must Enter the Number of Records to be Created!"
Exit Sub
End If
For I = 1 To varNumRecords - 1
If Me.Dirty Then Me.Dirty = False
varCartridge = Me.CartridgeType
DoCmd****nCommand acCmdSelectRecord
DoCmd****nCommand acCmdCopy
DoCmd.GoToRecord , , acNewRec
DoCmd****nCommand acCmdPaste
Me.CartridgeType = varCartridge
Next I
End Sub
Because of a quirk in this website, it won't allow us to type and display anything containing a
Dot (
.) followed by
ru, so in the code above, everwhere you see
DoCmd****nCommand
replace it with
DoCmd . RunCommand
simply
Deleting the spaces on either side of the
Dot.
Now all you need to do is
- Create a New Record and enter the Cartridge Type
- Enter the total number of Records you want to generate
- Click on the Button
Access will create the number of
Records (including the one already created) indicated with the given
CartridgeType.
You could use a
Combobox instead of a
Textbox, but that's really overkill in order to simply enter a number.
Linq
;0)>