I have a button, where if I click it, it will promt a MsgBox and InputBox before the action is done.
How do I stop the MsgBox from executing if I the InputBox is left blank or I click cancel at the InputBox?
Or is there a code that will only show the OK button?
Code:
Private Sub btnWorkDone_Click()
Dim WorkHours As Integer
On Error Resume Next
If Not (IsNull([datTransferIs]) Or IsNull([datTransferShould])) Then
WorkHours = InputBox("Actual working hours:", "Update Working Hours")
CurrentDb.Execute "UPDATE tblWork SET datActualTransfer = " & WorkHours & " WHERE lngTransferNr = " & [lngTransferNr] & ";"
If MsgBox("Are you sure you want to send this bill?", vbYesNo, "Billtransfer confirmation?") = vbYes Then
CurrentDb.Execute "UPDATE tblWork SET datMeasurementIs = '" & Date & "' WHERE lngTransferNr = " & [lngTransferNr] & ";"
Me.Requery
End If
Else: MsgBox "This Bill cannot be sent yet", vbCritical, "Error"
End If
End Sub
How do I stop the MsgBox from executing if I the InputBox is left blank or I click cancel at the InputBox?
Or is there a code that will only show the OK button?
Last edited: