Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why an extra record???

Status
Not open for further replies.

rbasram

Programmer
Sep 27, 2001
53
0
0
CA
I have a functiona that loop through a listbox and then adds a new the record into the table but after this procedure i get an extra blank record i have no idea why any suggetions...

Private Sub Command19_Click()

Dim lrsMyRecordSet As Recordset
Dim liLoop As Variant

Set lrsMyRecordSet = CurrentDb.OpenRecordset("test", dbOpenDynaset)

For liLoop = 0 To lstAllProduct.ListCount

lstAllProduct.Selected(liLoop) = True
lrsMyRecordSet.AddNew
lrsMyRecordSet("Pt") = Me.lstAllProduct.Column(0, liLoop)
lrsMyRecordSet("CT#") = Me.[txtCTracking]
lrsMyRecordSet("T#") = Me.[Tracking#]
lrsMyRecordSet("Pub#") = Me.[Publication#]
lrsMyRecordSet!Tt = Me.[txtTitle]
lrsMyRecordSet!DID = txtDocumentID
lrsMyRecordSet!AID = Me.txtAuthorName
lrsMyRecordSet.Update
Next liLoop


End Sub
 
Try changing the For statement to

For liLoop = 1 To lstAllProduct.ListCount


Craig
 
Hi! try this!

For liLoop = 1 To lstAllProduct.ListCount do



next liloop

Skep :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top