You can get Access to add a range for you by using a little unbound form to
enter this data.
1. Create a form with 3 text boxes named:
txtPrefix
txtFirstNum
txtLastNum
You will enter the prefix (ABC in your example) in the first box, the first
number (100 in your example) in the middle box, and the last number (e.g.
119) in the last box.
2. For the last 2 boxes, set these properties:
Format Fixed
Decimal Places 0
Validation Rule Between 0 And 999
3. Add a command button, and set these properties:
Name cmbAddPlates
On Click [Event Procedure]
4. Click the Build button (...) beside the On Click property.
Access opens the code window.
Set up the code so it looks like this:
Private cmdAddPlates_Click()
Dim rs As DAO.Recordset
Dim i As Integer
If IsNull(Me.txtPrefix) Or IsNull(Me.txtFirstNum) Or _
IsNull(Me.txtLastNum) Then
MsgBox "Enter the prefix, first number, and last number"
Else
Set rs = dbEngine(0)(0).OpenRecordset("RegistrationTable", _
dbOpenDynaset, dbAppendOnly)
For i = Me.txtFirstNum To Me.txtLastNum
rs.AddNew
rs![RegNumber] = Me.txtPrefix & Format(i, "000")
rs.Update
Next
End If
End Function
5. Substitute your table and field names in that code instead of
RegistrationTable and RegNumber. Then test that Access understands it by
choosing Compile on the Debug menu. Save. Test.
--
Allen Browne - Microsoft MVP. Perth, Western Australia
Reply to group, rather than allenbrowne at mvps dot org.
Debba said:
I am wanting to create a log of New Zealand registration numbers (car
number
plates) that have to be signed out when they are used. the plates are
sent
to me in order for example I will receive 20 plates and they will be;
ABC100
ABC101
ABC102
ABC103......ABC119
Is it possible to just log the first plate ABC100 into a table and then
have
the rest of the plates automatically fill in? Almost like an excel
spreadsheet? Ok i guess it would be wiser to go and use excel, i just
like
access!!