Here is what I want to do;
I want to change value of checkbox [Zavrseno] from false to true by selecting records in Listbox [tablica] in query [isporuka po policama]
I've assigned this code on command button:
Private Sub Izdano_Click()
Dim rs As DAO.Recordset
Dim ctl As Control
Dim varItm As Variant
Set ctl = Me![tablica]
Set rs = CurrentDb.OpenRecordset("SELECT [Zavrseno] FROM [isporuka po policama]")
With ctl
For Each varItm In .ItemsSelected
rs.Edit
rs!Zavrseno = True
rs.Update
DoCmd.RunCommand acCmdRefresh
Next varItm
End With
Exit_Here:
On Error Resume Next
rs.Close
Set rs = Nothing
Exit Sub
ErrorHandler:
MsgBox err.Number & vbCrLf & err.Description
Resume Exit_Here
End Sub
The problem is that it updates only first record in listbox if ANY record is selected...
Obviously the code is wrong (or something is missing).
Help!
THNX
I want to change value of checkbox [Zavrseno] from false to true by selecting records in Listbox [tablica] in query [isporuka po policama]
I've assigned this code on command button:
Private Sub Izdano_Click()
Dim rs As DAO.Recordset
Dim ctl As Control
Dim varItm As Variant
Set ctl = Me![tablica]
Set rs = CurrentDb.OpenRecordset("SELECT [Zavrseno] FROM [isporuka po policama]")
With ctl
For Each varItm In .ItemsSelected
rs.Edit
rs!Zavrseno = True
rs.Update
DoCmd.RunCommand acCmdRefresh
Next varItm
End With
Exit_Here:
On Error Resume Next
rs.Close
Set rs = Nothing
Exit Sub
ErrorHandler:
MsgBox err.Number & vbCrLf & err.Description
Resume Exit_Here
End Sub
The problem is that it updates only first record in listbox if ANY record is selected...
Obviously the code is wrong (or something is missing).
Help!
THNX