I'm trying to create a form that will allow the user to "mass update" multiple customers at the same time. The customers are listed as a list box and the user can multiple select. There are 13 fields on the form that the user can edit and I want any edited fields to be changed on all the selected customers, but if a field is not edited I want the field to stay the same.
It may be a problem just because I don't understand recordsets (any explanations are welcome!) or that I've designed it wrong, but I'm having problems in the following areas:
(1) with records being locked from a previous edit,
(2) the first record being changed, but the second one not changed at all (it leaves an orphan in the table)
(3) how can I leave the field alone when the one on the form is not changed
(4) how can I most efficiently check all 13 fields?
I'm inserting my code for anyone who will help!!
Thanks,
Jackie
It may be a problem just because I don't understand recordsets (any explanations are welcome!) or that I've designed it wrong, but I'm having problems in the following areas:
(1) with records being locked from a previous edit,
(2) the first record being changed, but the second one not changed at all (it leaves an orphan in the table)
(3) how can I leave the field alone when the one on the form is not changed
(4) how can I most efficiently check all 13 fields?
I'm inserting my code for anyone who will help!!
Thanks,
Jackie
Code:
Private Sub cmdClose_Click()
On Error GoTo Err_cmdClose_Click
Dim CurrentRow As Integer
Dim ctlSource As Control
Dim CustID As Integer
Dim myRS As Recordset
Dim myDB As Database
Dim strSQL As String
Set myDB = CurrentDb
Set ctlSource = Me!CustList
Set myRS = myDB.OpenRecordset("tTripCustomer")
For intCurrentRow = 1 To ctlSource.ListCount - 1
If ctlSource.Selected(intCurrentRow) Then
CustID = ctlSource.Column(0, intCurrentRow)
If myRS.RecordCount > 0 Then
' myRS.LockEdits = True
myRS.FindFirst ("[tcCID]=" & CustID)
If Not myRS.NoMatch Then
If IsNull(Me!tcAmtDue) = False Then
myRS.Edit
myRS("tcCID").Value = CustID
myRS("tcAmtDue").Value = Me!tcAmtDue
If IsNull(Me!tcPytMethod) = False Then
myRS("tcPytMethod").Value = Me!tcPytMethod
End If
myRS.Update
'myRS.LockEdits = False
End If
End If
End If
End If
Next intCurrentRow
myRS.Close
myDB.Close
DoCmd.Close
Exit_cmdClose_Click:
Exit Sub
Err_cmdClose_Click:
MsgBox Err.Description
Resume Exit_cmdClose_Click
End Sub