Set Focus / GoTo

Petros

Registered User.
Local time
Tomorrow, 00:06
Joined
Jun 30, 2010
Messages
145
Hi all,

why does this not function:

If Me![Fruits] = "Bananas" Then
DoCmd.Save
Forms![Form2].[Comments] SetFocus
End If

Forms2 is a subform

Thanks!
 
Hi all,

why does this not function:

If Me![Fruits] = "Bananas" Then
DoCmd.Save
Forms![Form2].[Comments] SetFocus
End If

Forms2 is a subform

Thanks!

Well, it could be several reasons.

1. Is the field FRUITS in your form's record source?

2. DoCmd.Save has nothing to do with saving a record.
DoCmd.RunCommand acCmdSaveRecord
is the right one to use.

3. A subform has different syntax than what you have there.

Forms!YourMainForm.SubformControlName.Form.ControlOnSubform

So, SubformControlName is the name of the control on the main form which houses the subform. It is not the name of the subform (unless the subform control and the subform are named exactly the same thing).

And the .Form. part is to be left EXACTLY as shown. It tells Access you want a property or method of the form and not the subform control that is on the main form.
 
I believe to move focus to a control on the subform you must first set focus to the subform itself.
 
I believe to move focus to a control on the subform you must first set focus to the subform itself.

Yes..that did it...

Why are the most simple solutions most difficult to understand? :)

Thanks indeed all for your asistance..i learned something new today!
 

Users who are viewing this thread

Back
Top Bottom