D
domibud
Hi...
I'm trying to update several fields in several records in a table.
I use a form for user input.
Here's the code that I use.
Private Sub ReleaseVoucher_Click()
On Error GoTo Err_ReleaseVoucher_Click
Dim SelectVoucher As Control
Dim CurrentRow As Integer
Dim strSQL As String
Dim dbs As DAO.Database
Set dbs = CurrentDb
Set SelectVoucher = Forms!AdmSubFrmVoucherRelease!AvailableVoucher
For CurrentRow = 0 To SelectVoucher.ListCount - 1
If SelectVoucher.Selected(CurrentRow) Then
strSQL = "UPDATE [AdmUsrTblBlueBirdMonitoring] SET
[AdmUsrTblBlueBirdMonitoring].[Employee] = 'Me.EmployeeName',
[AdmUsrTblBlueBirdMonitoring].[DateRelease] = #" & Me.DateRelease & "# WHERE
[#2-#8] = 'Me.AvailableVoucher'"
End If
dbs.Execute strSQL, dbFailOnError
Next CurrentRow
Exit_ReleaseVoucher_Click:
Exit Sub
Err_ReleaseVoucher_Click:
MsgBox Err.Description
Resume Exit_ReleaseVoucher_Click
End Sub
When I hit ReleaseVoucher button in form, I don't get any error message.
When I checked the table, the fields are not updates.
Any suggestion on how to make this works?
Thanks for your help.
I'm trying to update several fields in several records in a table.
I use a form for user input.
Here's the code that I use.
Private Sub ReleaseVoucher_Click()
On Error GoTo Err_ReleaseVoucher_Click
Dim SelectVoucher As Control
Dim CurrentRow As Integer
Dim strSQL As String
Dim dbs As DAO.Database
Set dbs = CurrentDb
Set SelectVoucher = Forms!AdmSubFrmVoucherRelease!AvailableVoucher
For CurrentRow = 0 To SelectVoucher.ListCount - 1
If SelectVoucher.Selected(CurrentRow) Then
strSQL = "UPDATE [AdmUsrTblBlueBirdMonitoring] SET
[AdmUsrTblBlueBirdMonitoring].[Employee] = 'Me.EmployeeName',
[AdmUsrTblBlueBirdMonitoring].[DateRelease] = #" & Me.DateRelease & "# WHERE
[#2-#8] = 'Me.AvailableVoucher'"
End If
dbs.Execute strSQL, dbFailOnError
Next CurrentRow
Exit_ReleaseVoucher_Click:
Exit Sub
Err_ReleaseVoucher_Click:
MsgBox Err.Description
Resume Exit_ReleaseVoucher_Click
End Sub
When I hit ReleaseVoucher button in form, I don't get any error message.
When I checked the table, the fields are not updates.
Any suggestion on how to make this works?
Thanks for your help.