using alist box for updating multiple records at once

hfs

Registered User.
Local time
Today, 02:46
Joined
Aug 7, 2013
Messages
47
Hi,
I have a list box populated with record ID's all of which need a date field updated. I have been succesful at using the list box to update single records, but am not sure how to transfer this idea to work with multiple records simultaneously.

The code i am using is:

Code:
Private Sub Command13_Click()
Dim i As Integer
    Dim strSQL As String
    Dim sMessage As String
    Set db = CurrentDb()
    Dim sTitle As String
    For i = List10.ListCount - 1 To 0 Step -1
    If List10.Selected(i) Then
    sSQL = "UPDATE test0 SET test0.date2 = now() " & " WHERE test0.itemno = '" & i & "'"
 
    sMessage = "Discontinue "
    sTitle = "Continue..."
    If MsgBox(sMessage, vbYesNo, sTitle) = vbYes Then
        MsgBox sSQL
        db.Execute (sSQL)
        
    End If
  
    End If
      Next i
End Sub
 
Thankyou so much for your help,the actual problem was to define record set in my code ,the code you send was very helpul and it worked .Thanks alot :)
 
You weren't using a recordset, but glad you got it working.
 

Users who are viewing this thread

Back
Top Bottom