Dear All
Hi, I’m trying to update a check box to True with an SQL statement in VBA. The code is below. Now when I use breakpoints the code shows it has picked up on the job_number text box on the fom, however the update of the check box doesn’t happen. The field job_number field is an autonumber number field set to long integer. I’ve persuaded the code to work by typing a job in directly, but it doesn’t seem to want to ‘pick up’ on the field if it’s offerred in the me.job_number format.
In the code I’ve got ‘-1’ for the True value, this is the third alternative, I’ve already tried True and ‘True’. I’ve used -1 successfull in code before, but only to refer to a check box on a form.
Private Sub JobNotFinishedBtn_Click()
On Error GoTo ErrHandler
Dim dBs As DAO.Database
Set dBs = CurrentDb
If IsNull(Me.BreakdownListCbo) Or IsNull(Me.True_Cause) Or IsNull(Me.RepairCarriedOutByCbo) Or IsNull(Me.Number_of_People_on_Job) Then
MsgBox “Please enter all the required Data”, vbOKOnly, “Data missing error”
DoCmd.GoToControl “BreakdownListCbo”
Else
DoCmd.RunCommand acCmdSaveRecord
dBs.Execute “UPDATE [Operator breakdown entry record] SET [New Job?] = ‘-1’ WHERE [Job Number] = ” & Me.Job_Number
DoCmd.RunCommand acCmdRecordsGoToNew
End If
ExitSub:
Set dBs = Nothing
Exit Sub
ErrHandler:
MsgBox Err.Number & ” ” & Err.Description
Resume ExitSub
End Sub
This is the first time I’ve trid to use the UPDATE statement in VBA and have just copied the relevant bits from the help file, I’m guessing that some where between the help file version and mine I’ve missd something, yet again..
Thanks
Ian