We've got a form to enter employee hours worked on a specific project. The hours worked are calculated within a macro which (simply said) takes the stop time and subtracts the start time. The macro itself works. Our problem is this: When the macro runs and either the start or stop time field is null, the macro errors.
We wanted to put in VB code that would prevent this from happening, but for some reason, we can't get it to work out. We've tried many different combinations of if/then/else/exit sub/goto/etc. Here's one of the better ideas we came up with that did not work:
Whichever way we organize this however, either the macro still runs and we get the error, or the macro does not run when it should. Is there something at all we are missing in the code, or is this something that Access can't handle (though I doubt that)?
We wanted to put in VB code that would prevent this from happening, but for some reason, we can't get it to work out. We've tried many different combinations of if/then/else/exit sub/goto/etc. Here's one of the better ideas we came up with that did not work:
Code:
Private Sub StopTime_AfterUpdate()
Dim strMacro As String
strMacro = "PayrollStartStopUpdate"
If Me.[StartTime] = Null Or Me.[StopTime] = Null Then
Exit Sub
Else
DoCmd.RunMacro (strMacro)
End If
End Sub
Whichever way we organize this however, either the macro still runs and we get the error, or the macro does not run when it should. Is there something at all we are missing in the code, or is this something that Access can't handle (though I doubt that)?