Forcing form elements to be updated

Tezdread

Registered User.
Local time
Today, 11:47
Joined
Jul 11, 2002
Messages
105
Hi,

I have a form with a couple of sub forms, one of the sub forms only has a check box and a txt field and both are required before moving on to another record.

I have this following code that works partly, but it only works if one of the fields have info entered. It doesn't however stop the user from tabing through the sub form without entering 'any' data in either one.

---------------------------------------

Private Sub Form_BeforeUpdate(Cancel As Integer)
If Trim(Me!txtContactAgentName & "") = "" Then 'Validate Name Field
MsgBox "Gotta Enter Your Name!"
Me!txtContactAgentName.SetFocus
Cancel = True
ElseIf Me!ynCCContactLogLeft <> True Then 'Validate CheckBox
MsgBox "Gotta Have a checkmark in Logged!"
Cancel = True
End If
End Sub
---------------------------------------------
Also the below throws up an error when I know it's got all the correct information.
------------------------------------
Private Sub txtContactAgentName_LostFocus()
Forms.frmAllCustInfo.SetFocus
Forms.frmAllCustInfo![AddNewCustomerRecord].SetFocus
End Sub

-------------------------------------

Can anyone advise?

thanks in advance
 
thanks guys, I'll look into that RuralGuy
Pat, not sure what you mean? When I remove the code form the form and leave the setfocus code only
---------------------------------------------------
Private Sub txtContactAgentName_LostFocus()
Forms.frmAllCustInfo.SetFocus
Forms.frmAllCustInfo![AddNewCustomerRecord].SetFocus
End Sub
-----------------------------------------------------

it works fine?
 

Users who are viewing this thread

Back
Top Bottom