Copy fill?

D

Debba

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!!
 
A

Allen Browne

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.
 
D

Debba

Thats brilliant thanks alot for your help.

Allen Browne said:
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!!
 
D

Debba

Ok this is all working fine, just now I am wanting to do the same thing
except have the range automatically add not the next number in sequence but
the next one after 30. for example; the first number is ABC100 the next i
want to be is ABC129 so go up in multiples of 30. thanks

Debba said:
Thats brilliant thanks alot for your help.
Allen Browne said:
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!!
 
A

Allen Browne

Use Step in the loop, e.g.:
For i = Me.txtFirstNum To Me.txtLastNum Step 30


--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Debba said:
Ok this is all working fine, just now I am wanting to do the same thing
except have the range automatically add not the next number in sequence
but
the next one after 30. for example; the first number is ABC100 the next i
want to be is ABC129 so go up in multiples of 30. thanks

Debba said:
Thats brilliant thanks alot for your help.
Allen Browne said:
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.

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!!
 
D

Debba

Magic thanks again.

Allen Browne said:
Use Step in the loop, e.g.:
For i = Me.txtFirstNum To Me.txtLastNum Step 30


--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Debba said:
Ok this is all working fine, just now I am wanting to do the same thing
except have the range automatically add not the next number in sequence
but
the next one after 30. for example; the first number is ABC100 the next i
want to be is ABC129 so go up in multiples of 30. thanks

Debba said:
Thats brilliant thanks alot for your help.
:

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.

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!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top