D
dfeigen115
I'm stumped, so here goes. I have a form that uses a multiselect listbox.
The source of the listbox data is a query from TABLE A. The list box is
populated using a basic select statement as part of the listbox control.
After selecting the entries in the list box, I have a control button that
excutes a procedure to idenitfy the selected items in the listbox and then
update a corresponding record in TABLE B. The update to TABLE B is working
as planned, however an unintended byproduct is that somehow, the process is
updating (blanking out) the field in TABLE A that cooresponds to the first
entry in the listbox (the bound column). This occurs regardless of whether
the first entry was selected for processing or not and it only impacts the
first entry in the listbox.
A copy of the update procedure is pasted below...
-------------------------------------
Dim intCurrentRow As Integer
Dim strSQL As String
Dim holdDate As Date
For intCurrentRow = 0 To Me.ExtendChargeNumber.ListCount - 1
If Forms!ApplyCNExtensions!.ExtendChargeNumber.Selected(intCurrentRow) Then
holdDate = FormatDateTime(Me.ExtendChargeNumber.Column(1, intCurrentRow),
vbShortDate)
strSQL = "UPDATE CostAccountNumber SET CAPOPEnd = '" & holdDate & "'
where (CostAccountNumber.CANumber = '" &
Forms!ApplyCNExtensions!ExtendChargeNumber.Column(0, intCurrentRow) & "');"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
End If
Next intCurrentRow
MsgBox ("The POP extension updates have been completed for the selected
charge numbers")
DoCmd.Close
The source of the listbox data is a query from TABLE A. The list box is
populated using a basic select statement as part of the listbox control.
After selecting the entries in the list box, I have a control button that
excutes a procedure to idenitfy the selected items in the listbox and then
update a corresponding record in TABLE B. The update to TABLE B is working
as planned, however an unintended byproduct is that somehow, the process is
updating (blanking out) the field in TABLE A that cooresponds to the first
entry in the listbox (the bound column). This occurs regardless of whether
the first entry was selected for processing or not and it only impacts the
first entry in the listbox.
A copy of the update procedure is pasted below...
-------------------------------------
Dim intCurrentRow As Integer
Dim strSQL As String
Dim holdDate As Date
For intCurrentRow = 0 To Me.ExtendChargeNumber.ListCount - 1
If Forms!ApplyCNExtensions!.ExtendChargeNumber.Selected(intCurrentRow) Then
holdDate = FormatDateTime(Me.ExtendChargeNumber.Column(1, intCurrentRow),
vbShortDate)
strSQL = "UPDATE CostAccountNumber SET CAPOPEnd = '" & holdDate & "'
where (CostAccountNumber.CANumber = '" &
Forms!ApplyCNExtensions!ExtendChargeNumber.Column(0, intCurrentRow) & "');"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
End If
Next intCurrentRow
MsgBox ("The POP extension updates have been completed for the selected
charge numbers")
DoCmd.Close