Results 1 to 10 of 10
  1. #1
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    1,644

    Right-Click popup - Function not found???

    I have a popup triggered with a right-click. The one option shown has as its "On Action" property "=MyFunction()". MyFunction is located in the code-sheet of the form for which the custom "Shortcut Menu Bar" is declared. E.g., the popup menu is named "R-Click" and the "Shortcut Menu Bar" in the form's property sheet specifies that popup. The code in the code sheet is simply:

    Public Function MyFunction()
    [snip]
    End Function

    A2003 claims it can't find the function.

    Does the function need to be in a general module? If not, what am I missing?

    Thanks,
    Bill

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    50,431
    A function can be called from the same form or report module that the function is behind.

    If you want to call a function from one form or report that is behind another form or report, need to precede the function call with the form or report name, otherwise put the function in a general module.

    What is the method you used to create the custom right-click? I think for this you will have to put the function in a general module.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    1,644
    I just stumbled onto the problem. The function needs to be in the code-sheet of the parent form. As it is/was, the function was located in the code-sheet of the sub-form upon which I was triggering a right-click action.

    Bummer! With the function in the code-sheet of the parent, I loose knowing the recordID and record field upon which the right-click occurred. If there's a way, I don't know what it is.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    50,431
    What are you trying to do? You are clicking on record in a subform to filter main form? Don't see how that can work. Children don't dictate to parent.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    1,644
    Child not wanting to dictate to parent. Child wants right-click action upon child text-box controls to be handled by child's code. Can't happen if control is forced to parent code. Parent has no knowledge of which control got right-clicked. I will use different approach with double-click on control and use popup form. Too bad, inconsistent with typical Windows operation of right-click to obtain options relating to object.
    Thanks,
    Bill

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    21,907
    Do you need to know which control was right-clicked on, or just which record? In my experience the right-click gives focus, so I have right-click menus that call public functions in standard modules, and in the function I refer to the ID field/control of the subform. I get the correct record. If you need the control, this should work:

    Screen.ActiveControl.Name
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    1,644
    Hi Paul,
    I will resume work on this in the AM. I think you're right about where the focus is at the time of the right-click. I'll verify that with some test code to be sure I know what record has the focus. If that's correct, I'll use your suggestion and see if I can complete the intended task. I'll post back tomorrow.
    Bill

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    21,907
    No problem Bill.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    1,644
    Couldn't wait. Everything works great. I can access the name of the control, the contents of the control and other fields of the current record, i.e., the record of interest has the focus.


    Thanks,
    Bill

  10. #10
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    21,907
    Happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Specified SQL server not found
    By danparker in forum Access
    Replies: 3
    Last Post: 10-25-2011, 03:23 PM
  2. Auto mail function for on click
    By edzigns in forum Access
    Replies: 4
    Last Post: 04-29-2011, 12:08 PM
  3. if found
    By newtoAccess in forum Queries
    Replies: 4
    Last Post: 03-03-2011, 09:25 PM
  4. "No Record Found" Function
    By viper in forum Programming
    Replies: 8
    Last Post: 02-09-2011, 09:52 AM
  5. If Not Found, then New?
    By gracysaurus in forum Programming
    Replies: 1
    Last Post: 08-17-2010, 04:58 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums