Results 1 to 6 of 6
  1. #1
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

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

    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

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

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

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

  3. #3
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

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

    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

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

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

    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.
    Charlotte

  5. #5
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

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

    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 (

  6. #6
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

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

    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
    Charlotte

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •