Hi, Hopeosmeone could help me with this.
I have a application where by when a number is entered (using text box on a form at the moment) it retrieves a record from the form, and I want it to toggle a checkbox.
If I enter the number, and the box is checked, I want to uncheck, and visa versa (so if not checked I want it to check it)
The entered text will come from a hand scanner. So, I scan a barcode, and I want the application to automatically check/uncheck the box depending on its current state, but only for the record corresponding to the number entered.
Code I have so far is:
Public Function onoffyes()
Dim strOnoffyes As String
strOnoffyes = "UPDATE crew " & _
"SET crew.onoff = yes " & _
"WHERE crew.ID = " & Forms!crew!Barcode
DoCmd.RunSQL strOnoffyes
End Function
Public Function onoffno()
Dim strOnoffno As String
strOnoffno = "UPDATE crew " & _
"SET crew.onoff = yes " & _
"WHERE crew.ID = " & Forms!crew!Barcode
DoCmd.RunSQL strOnoffno
End Function
Private Sub Barcode_lostfocus()
Dim varOnoff As String
varOnoff = DLookup("onoff", "crew", "ID = " & Me.Barcode)
If varOnoff = no Then
Call onoffno
ElseIf varOnoff = yes Then
Call onoffyes
End If
Me.Refresh
End Sub