Refer to parent form in standard module

wind54surfer

Registered User.
Local time
Today, 12:24
Joined
Jan 19, 2005
Messages
31
Hi all,

I have a Form with a combo box that I access by pressing F6 with the
following function (converted from a Autokey macro):

Function AutoKeysF6()
On Error GoTo AutoKeysF6_Err

' Find PO#
DoCmd.GoToControl "FindPO"

AutoKeysF6_Exit:
Exit Function

AutoKeysF6_Err:
MsgBox Error$
Resume AutoKeysF6_Exit

End Function

This works OK when I open the form but when the focus is in any of the subforms it doesn't work.

I use this same combo box in many forms and want to find a way to
refer to the parent form that somehow will let me use the function in a
general way.

I tried "Me.Parent!FindPO" but it doesn't work because the function is not in a class module.

I know I could use the macro Autokeys but the reason I converted to a code was because I have to keep track on every form to cancel F6 to make sure If I press F6 by mistake don't get an error.


I am still a newbie and can't figure it out.

Any help would be greatly appreciated.

Emilio
 
Try:
Code:
Function AutoKeysF6()
On Error GoTo AutoKeysF6_Err

' Find PO#
''''' Do not use the following line
' DoCmd.GoToControl "FindPO"
''''' Use the following line instead
[b]Me.Parent.FindPO.SetFocus[/b]

AutoKeysF6_Exit:
Exit Function

AutoKeysF6_Err:
MsgBox Error$
Resume AutoKeysF6_Exit

End Function
 

Users who are viewing this thread

Back
Top Bottom