Hi all - I'm struggling to work out why a response MsgBox keeps popping up twice before moving on to the next box would be depending on the response being either yes or no. I'm sure its something simple that wrong with the code I've written but for some reason just can't see what's wrong so would be grateful if someone with better knowledge than me could work out what I'm doing wrong or missing.
The problem is with the last part of the sub and the msgbox
The full code in the sub is:
Many thanks for any replies Paul
The problem is with the last part of the sub and the msgbox
VBA Code:
MsgReply = MsgBox("Does this expense relate to a date period (i.e. between two dates)?", vbQuestion + vbYesNo, "Expense Date Required")
The full code in the sub is:
VBA Code:
Private Sub txbExpAmount_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim MsgReply As VbMsgBoxResult
If Not IsNumeric(txbExpAmount.Value) And txbExpAmount.Value > "" Then
MsgBox "It looks like you've entered a text value. Please only enter a numeric value greater than 0.", vbExclamation, "Invalid Entry"
Cancel = True
txbExpAmount.Value = ""
txbExpAmount.SetFocus
txbExpAmount.SelStart = 0
txbExpAmount.SelLength = Len(txbExpAmount.Value)
txbExpAmount.BackColor = RGB(204, 255, 255)
ElseIf txbExpAmount.Value = "" Then
MsgBox "It looks like you've left this box empty. Please only enter a numeric value greater than 0. ", vbExclamation, "Invalid Entry"
Cancel = True
txbExpAmount.Value = ""
txbExpAmount.SetFocus
txbExpAmount.BackColor = RGB(204, 255, 255)
ElseIf txbExpAmount.Value = "0" Then
MsgBox "The total expense amount needs to be a value greater than 0. Please only enter a numeric value greater than 0.", vbExclamation, "Invalid Entry"
Cancel = True
txbExpAmount.Value = ""
txbExpAmount.SetFocus
txbExpAmount.BackColor = RGB(204, 255, 255)
Else
If txbExpAmount.Value > "0" Then
MsgReply = MsgBox("Does this expense relate to a date period (i.e. between two dates)?", vbQuestion + vbYesNo, "Expense Date Required")
If MsgReply = vbYes Then
txbExpDate.Enabled = False
txbPeriodFrom.SetFocus
txbExpAmount.Value = Format(txbExpAmount.Value, "£0.00")
Else
txbExpDate.Enabled = True
txbExpDate.SetFocus
End If
End If
End If
End Sub
Many thanks for any replies Paul