Error with Event Procedure

nyrob609

Registered User.
Local time
Yesterday, 19:41
Joined
May 22, 2009
Messages
46
Hi,

I am having an issue with the event procedure below. I have a form that has several sub forms and what I want is that if the user chooses Plan Name in the main form "No Fault" or 'Workers Comp". I want message to pop and go to the field in the subform to enter data but I keep on getting an error.

Private Sub Plan_Name_AfterUpdate()
If ([Plan Name] = "No Fault") Then
MsgBox "Enter additional information in No Fault form before continuing."
DoCmd.GoToControl ([NoFaultWCompsubForm]![Attorney Name])
End If

End Sub

It says the action or method requires a control name argument?????

What am I missing????

Thanks
 
Don't use DoCmd.GoToControl.

Just set it but you have to use the Subform CONTROL name (control on the parent form which houses/displays the subform) and NOT the name of the subform itself unless they both are named exactly the same.

If named the same you can use

Me.SubFormControlNameHere.AttorneyName.SetFocus

If NOT the same you need to use

Me.SubFormControlNameHere.Form.AttorneyName.SetFocus

Where the .FORM. part is left exactly as it is shown (you don't substitute a name or anything for it). What that is telling Access is that you are referring to a property or method on the subform itself and not the subform control If they are named the same then you can omit it because it will be the default.

Also, you may find you need to set the focus on the subform first

Me.SubFormControlNameHere.Form.SetFocus
Me.SubFormControlNameHere.AttorneyName.SetFocus

like that.
 

Users who are viewing this thread

Back
Top Bottom