Thanks
Hi John
Thanks for that. Gave it a try and it does what I want, but there is one small problem, I was hoping you could help me with.
The code works and highlights the field as being invalid. However, it still procedues to the next record. Can you tell me what is wrong with my code. I suspect it is the docmd.cancelevents at the end of the code, but not sure how to fix it. Thanks Marcus
Dim MyPracticeName, MyPracticeCode, MyPracticeLocation, MyVisionEmis
Dim PracticeNameFalse, PracticeCodeFalse, PracticeLocationFalse, VisionEmisFalse
MyPracticeName = Me.txtPracticeName & ""
MyPracticeCode = Me.txtPracticeCode & ""
MyPracticeLocation = Me.txtaddress1 & ""
MyVisionEmis = Me.cmbvisionemis & ""
Select Case MyPracticeName
Case Is = ""
Me.txtPracticeName.BackColor = "8421631"
PracticeNameFalse = "False"
MsgBox "Please enter a practice name", vbCritical
Case Else
Me.txtPracticeName.BackColor = "8421631"
PracticeNameFalse = "True"
Me.txtPracticeName.BackColor = "16777215"
End Select
Select Case MyPracticeCode
Case Is = ""
Me.txtPracticeCode.BackColor = "8421631"
PracticeCodeFalse = "False"
MsgBox "Please enter a practice code", vbCritical
Case Else
Me.txtPracticeCode.BackColor = "16777215"
PracticeCodeFalse = "true"
End Select
Select Case MyPracticeLocation
Case Is = ""
Me.txtaddress1.BackColor = "8421631"
PracticeLocationFalse = "False"
MsgBox "Please enter the first line of the address for the practice location", vbCritical
Case Else
Me.txtaddress1.BackColor = "16777215"
PracticeLocationFalse = "true"
End Select
Select Case MyVisionEmis
Case Is = ""
Me.cmbvisionemis.BackColor = "8421631"
VisionEmisFalse = "False"
MsgBox "Please select whether or not this is a vision or Emis practice", vbCritical
Case Else
Me.cmbvisionemis.BackColor = "16777215"
VisionEmisFalse = "true"
End Select
If PracticeNameFalse <> "False" And PracticeCodeFalse <> "False" And PracticeLocationFalse <> "False" And _
VisionEmisFalse <> "False" Then
DoCmd.CancelEvent
End If
End Sub