erroneous data updates in table

G

Guest

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
 
G

Guest

Not sure why it would update TableA, but you probably don't need to have the
listbox bound. Does it have the ControlSource property set? You should clear
this.

Barry
 
G

Guest

That worked. I did have the ControlSource property set to table A, removing
the property got rid of the unwanted updates.
Thanks for you time in reviewing my issue.
Dan
 

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