Results 1 to 8 of 8
  1. #1
    d9pierce1 is offline Expert
    Windows 10 Access 2019
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    776

    Click button on sub form to call click on the parent form?

    Hi all,
    Just cant seam to get this to work? I am trying to click a button on a subform to click a button on primary form?
    I have used this before but get an error message? not defined...



    Private Sub CmdInventory_Click
    Call Me.Parent.CmdInventoryList_Click
    End Sub

    Have the correct spelling, have tried Forms.frmAccountHolder.CmdInventoryList_Click
    and nothing works?
    What am I doing wrong here
    Thanks
    Dave

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Is the main form button click event declared as Public instead of Private?
    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
    d9pierce1 is offline Expert
    Windows 10 Access 2019
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    776
    Hi June7
    It is private, I will try making it public?
    Have also tried this
    Call Form_frmAccountHolder.CmdInventoryList_Click

  4. #4
    d9pierce1 is offline Expert
    Windows 10 Access 2019
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    776
    OK, Made it a public and now I get this error?
    "You cant hide a control that has the focus"
    Any solutions?
    Wow....
    Thanks

  5. #5
    d9pierce1 is offline Expert
    Windows 10 Access 2019
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    776
    OK, Its Fixed... Thank you
    Private Sub CmdInventory_Click
    Forms!frmAccountHolder!CmdInventoryList.SetFocus
    Call Me.Parent.CmdInventoryList_Click
    End Sub

    Works beautifully
    Marked as solved


  6. #6
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,945
    Why are you not using Parent for the setfocus?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  7. #7
    d9pierce1 is offline Expert
    Windows 10 Access 2019
    Join Date
    Jan 2012
    Location
    Oklahoma
    Posts
    776
    Not real sure, I could perhaps
    Will try that out and see if that works!
    Thanks

  8. #8
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,945
    You really should try to be consistent in your code.
    It will help you later, when you have to come back to it.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

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

Similar Threads

  1. Need to click button twice on form
    By VinnieM in forum Forms
    Replies: 8
    Last Post: 11-26-2022, 09:42 AM
  2. vba to click button on another form
    By mainerain in forum Programming
    Replies: 3
    Last Post: 05-21-2020, 10:14 AM
  3. Call a button click from another form
    By Rgaming in forum Access
    Replies: 3
    Last Post: 10-16-2017, 12:54 PM
  4. Call Click event in nagivation button from subform
    By Malalex in forum Programming
    Replies: 2
    Last Post: 02-05-2017, 06:33 PM
  5. External script to call Command Button Click event handler
    By Sean Nakasone in forum Programming
    Replies: 5
    Last Post: 10-29-2014, 12:35 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