mardi 16 février 2021

My if block in my access vba code doesn't execute(is ignored completely) even though the condition is True

I am writing a code that takes checks if the value of the action box is Serviced and then outputs, you have chosen Serviced and then adds the data of the form to the Service_Tracker table.

enter image description here

It was working fine sometime ago but now it doesn't. There are no errors, no mistakes, nothing.

Microsoft access just completely ignores the "if" statement completely. Please I really need help. And I have already set the db= CurrentDb Here is the code

If Me.Action_Box.Value = "Serviced" Then
    MsgBox ("YOU CHOSE SERVICED")
    Dim service_track As Recordset
    Set service_track = db.OpenRecordset("Service_Tracker")
    service_track.AddNew
        service_track![company_name] = Me.Comp_Box.Value
        service_track![site_name] = Me.site_box.Value
        service_track![Serviced_Date] = Me.sched_date_box.Value
        service_track![Status_Date] = Me.stat_date_box.Value
    service_track.Update
    MsgBox ("It hass been added to the database")
End If

enter image description here

Aucun commentaire:

Enregistrer un commentaire