By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,510 Members | 1,821 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,510 IT Pros & Developers. It's quick & easy.

How do I append a series of numbers from...to?

P: n/a
I have a table which holds certification numbers that come in batches. The
numbers will run from (for example) 456 to 496. I have to enter these
numbers individually. Is there a code I could use to append from 456 to 496
to the table? I'd like a pop up form that prompts for the number from and
the number to.
Aug 22 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a

Robert Waggoner wrote:
I have a table which holds certification numbers that come in batches. The
numbers will run from (for example) 456 to 496. I have to enter these
numbers individually. Is there a code I could use to append from 456 to 496
to the table? I'd like a pop up form that prompts for the number from and
the number to.
create an unbound form. put two textboxes on it. Format them as
numbers. (so you can't do something like assign a text value to one of
them). Then you need a button on your form to execute some code to do
this.

dim rs as dao.recordset
dim lngCurrentValue as Long

set rs =
dbEngine(0)(0).OpenRecordset("TableRecordsGetAppen dedTo",dbOpenTable,dbAppendOnly)

'grab the start and stop values from your open form.
For lngCurrentValue = Me.txtStartValue to Me.txtStopValue
rs.AddNew
rs.Fields("YourFieldName")= lngCurrentValue
'---set values for any other fields here if you need to
change their defaults
rs.Update
next lngCurrentValue

rs.close
set rs=nothing

Aug 22 '06 #2

P: n/a
okay, I actually tested this one...
I have a form, which is *not* bound to a table.
On it are
a textbox, "txtPersonID", which is formatted as a Fixed number, 0
decimal places.
a series of checkboxes for some states. (This is a test - I only made
4, but that's not really relevant.)
I changed the .Tag property of each checkbox to the 2-letter
abbreviation for the state it represented. (Sorry, that's going to be
tedious)
Then I added a button with this code attached:
Private Sub Command8_Click()

Dim rs As DAO.Recordset
Set rs = DBEngine(0)(0).OpenRecordset("tblResidence", dbOpenTable,
dbAppendOnly)

Dim ctl As Control

For Each ctl In Me.Controls
If TypeOf ctl Is CheckBox Then
If ctl = True Then
rs.AddNew
rs.Fields("PersonID") = Val(Me.txtPersonID)
rs.Fields("State") = ctl.Tag
rs.Update
End If
End If
Next ctl

rs.Close
Set rs = Nothing

End Sub

Aug 22 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.