PDA

View Full Version : Solved: Listbox Loop in Query update



slamet Harto
10-22-2011, 06:24 PM
Hi there
Hope you are doing good.

Do me a favor, if I want to update some records on all selected list in a listbox

With the following syntax, I get stuck with error message - Too few parameter

Private Sub CmdUpdate_Click()
Dim iloop As Long

Call Connect 'sub function on connection string

For iloop = 1 To MyList.ListCount
If MyList.Selected(iloop - 1) = True Then

cn.Execute "Update tblPPDC set DateRcvd= Trim(TextBox1.Text) where LRF_No='" & Trim(Me.MyList.List(Me.MyList.ListIndex, 0)) & "'", , adCmdText

Me.MyList.ListIndex = Me.MyList.ListIndex - 1
MyList.Selected(iloop - 1) = False
End If
Next
cn.Close
Set cn = Nothing
End Sub

Any kind of suggestion, would be much appreciated it
Harto

mdmackillop
10-23-2011, 05:02 AM
I suspect this should be in quotes "Trim(TextBox1.Text)"
Try debug.print the execute statement to see if it looks right.

slamet Harto
10-23-2011, 05:32 AM
Hi Malcom
Thanks so much, you made my day!:friends: