• Conditional use of AutoKeys Macro? (A2k (9.0.4402) SR-1)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Conditional use of AutoKeys Macro? (A2k (9.0.4402) SR-1)

    Author
    Topic
    #361593

    I have FormA with Control TabA and Control TabB that uses

    F3 Key with SendKeys to move focus to to Control TabB, and
    F2 Key with SendKeys to move focus to to Control TabA

    Everything works fine.

    I want to have a new FormB that uses Function Keys as follows:

    F2 Key that loads FormC, and
    F3 Key that loads FormD

    Question: What is the proper Macro condition syntax to determine/test which Form the Function Keys came from?

    Thanks, John Graves

    Viewing 0 reply threads
    Author
    Replies
    • #547154

      You can try testing for Screen.ActiveFom.Name = “FormA”, but this would be much easier to handle with code instead of a macro.

      • #547332

        Hi Charlotte

        Your sugestion worked fine, however looks like I can only define {F2} once in a macro.

        Do you have any VBA kicking around that automates AutoExec using code?, can you point me to examples?

        Thanks, John

        • #547373

          You can only define any AutoKey once in the macro. What I was suggesting wasn’t defining it twice, it was changing the behavior depending on which form was open and using the elipsis (…) to group actions together. You would still only define it once.

          You don’t automate AutoExec from code, you call the code from AutoExec. Or did you mean AutoKeys? In that case, you don’t do it that way. Instead, you use the Key events of a form and/or its controls (i.e., OnKeyPress), to see what key has been pressed and then respond accordingly. Type “keypress event” (without the quotes) in the Answer Wizard input box in on-line help and it will give you the lowdown, including examples.

          • #547483

            Thanks, that is exactly what I wanted but didn’t know how to ask the question, following is my solution for other newbees.

            Is there any to rewrite the following command so I’m not hardcoding the main for name from the subform?

            Forms!frm_TOC_BP_ACD!cboLookupSequence.SetFocus ‘Move Focus to Lookup Seq Control

            =============================
            Private Sub Form_Load()

            ‘ KeyPreview Property Example

            ‘ In the following example, the KeyPreview property is set to True (

            • #547603

              But why are you using SendKeys at all? You can just use SetFocus to set the focus directly. So instead of this:

              SendKeys “%p”, False ‘Move Focus to Permit Information Tab

              use whatever the name of the Tab page is and do this (where Page1 represents the name of the Tab page:

              [Page1].SetFocus

              Is frm_TOC_BP_ACD the subform’s parent form? If so, just use Me.Parent!cboLookupSequence.SetFocus

    Viewing 0 reply threads
    Reply To: Conditional use of AutoKeys Macro? (A2k (9.0.4402) SR-1)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: