Hi I have a userform that a user can use to edit/amend a record already entered and then writes any amended data back to the sheet.
The textboxes on the edit form are populated from a worksheet.
I'm having a problem coding a textbox exit routine to check that if a user edits the box and enters something other than the 3 allowed words it fires a msgbox. The code below does actually work but it also fires even if 1 of the 3 words is entered. e.g. If the textbox contains PayPal when the form opens and I then type in Bacs or Stripe is still fires the msgbox.
Would someone be knid enough to let me know what I'm doing wrong please?
Many thanks Paul
The textboxes on the edit form are populated from a worksheet.
I'm having a problem coding a textbox exit routine to check that if a user edits the box and enters something other than the 3 allowed words it fires a msgbox. The code below does actually work but it also fires even if 1 of the 3 words is entered. e.g. If the textbox contains PayPal when the form opens and I then type in Bacs or Stripe is still fires the msgbox.
Would someone be knid enough to let me know what I'm doing wrong please?
Many thanks Paul
VBA Code:
Private Sub textboxPayMeth_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If (textboxPayMeth.Text) <> "PayPal" Or (textboxPayMeth.Text) <> "Stripe" Or (textboxPayMeth.Text) <> "Bacs" Then
MsgBox "You have entered an invalid payment method, you can only use Paypal, Stripe or Bacs. Please re-enter the payment method using 1 of these 3 methods.", vbInformation, "Invalid Entry"
Cancel = True
textboxPayMeth.SetFocus
textboxPayMeth.Value = ""
textboxPayMeth.BackColor = RGB(204, 255, 255)
End If
End Sub