loop to assign numbers in a table

T

tgl

I'm importing addresses from a text file (name/address/city state zip) to an
access table "TABLE".
I want to put into proper fields, so first i autonumbered an "autonumber"
field to keep in order. i thought i would loop thru records, assigning to
"number": 1 to the name, 2 to the address, 3 to city state zip and then if
nothing in field assign 0.

this doesn't work as an event procedure, and i'm not sure why, does anyone?
thanks:

Private Sub Command3_Click()

Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb

Dim numbernew As String

Set rs = db.OpenRecordset("Select * From TABLE Order By autonumber")
With rs
..MoveFirst
numbernew = 0
Me!number = 0
Do Until rs.EOF

..MoveNext
If rs![DONE] = "DONE" Then
Exit Do
End If

If IsNull(rs!Field1) Then rs!number = 0 Else rs!number = numbernew + 1
numbernew = rs!number




Loop


End With

End Sub
 

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