Results 1 to 15 of 15
  1. #1
    Miles R is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Mar 2019
    Posts
    176

    Putting command button in front of Subform

    I have a Subform which is a Continuous Form on my main application form. This form is for reference purposes and is not interactable with.
    I want to put a transparent Command Button in front of it so that I can click on the Command Button rather than the SubForm.
    However, the SubForm always seems to be On Top even when I send it to the back. Is this by design that Subforms are always on top?

    The problem with the Subform is that I can set a click event on the detail but it only seems to react when I click the top row (i.e. current row) of the form.
    I need it to trigger a click event when I click anywhere in the Subform. Might have to use some sort of MouseDown event when inside the perimeter of the Subform.

  2. #2
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    I want to put a transparent Command Button in front of it
    So the button is not on the subform? Pretty sure the subform would be higher in the z order than the button if the button isn't on the subform. Clicking on a subform detail section and not a record works for me though.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    As far as I can tell, the only control that can set on top of a subform container is another subform container.

    Could set form AllowAdditions, AllowDeletions, AllowEdits, AllowFilter properties to No then have button in form header section.
    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.

  4. #4
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,566
    What do you want to happen when you click the Command Button?
    You can PM me if you need further help.
    Good Reading https://docs.microsoft.com/en-gb/off...on-description

  5. #5
    Miles R is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Mar 2019
    Posts
    176
    I want to open another form.

  6. #6
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,566
    Well all you need to do is create a Command Button in the Header of the Subform

    Then in the Onclick event put:-

    DoCmd.OpenForm "frmName"
    You can PM me if you need further help.
    Good Reading https://docs.microsoft.com/en-gb/off...on-description

  7. #7
    Miles R is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Mar 2019
    Posts
    176
    No, the button is on the Main Form overlaying the Subform - except it is not - it is behind it which is not what I want. You are probably right about the z order, but that does not solve my problem.
    I have more or less got round some of it by adding click events to the Subform Header, Detail and labels in the header.
    So it more or less works but not to my exacting standards. I want a Hand to appear on the form when hovering over the subform - which I could do with a button, but not on most of the subform click events.
    Much as I love Access, I always seem to be having to invent clever work arounds for things that ought to be easy.

  8. #8
    Miles R is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Mar 2019
    Posts
    176
    Yes that would work for the header, but can I put a command button covering all of the Detail section - remembering that this is a continuous form?
    I'll try that later.
    Thanks for the tip.

  9. #9
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    Put the button on the main form? Use click or double click event on subform detail section (but not sure what "This form is for reference purposes and is not interactable with" means) - so disable form controls if need be?

    EDIT - wish this forum would notify us when there are new posts during a response post...

    Consider posting a db with your form and just enough to make it work. Who knows what anyone might come up with?
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  10. #10
    Miles R is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Mar 2019
    Posts
    176
    Mike, just tried putting a command button on the header, but can't get it to respond to a click event. Can't figure out why not.
    Strangely, if I put a label covering the entire header, it will respond to a click event.
    Not sure what is going on here!

  11. #11
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,566
    Hi

    Can you upload a zipped copy of the Database?
    You can PM me if you need further help.
    Good Reading https://docs.microsoft.com/en-gb/off...on-description

  12. #12
    Miles R is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Mar 2019
    Posts
    176
    Further info. Just opened the sub-form directly and the command button in the header works perfectly.
    However, it does not work when clicking on the command button when it is a sub-form in my main form.
    Something must be disabling that function. Probably have to find another work around.

    p.s. Saw the Good Reading link, but having spend 20 years as a professional database programmer (Ingres, with C and Unix), I might give that a miss.
    Just do hobby Access programming now, to keep my hand in (as well as c# Chess programming).

  13. #13
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    Put a breakpoint on first line of executable code and step through 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

  14. #14
    Miles R is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Mar 2019
    Posts
    176
    Ok, found what was wrong with the Command Button not responding from the main form. I had the sub-form set to Disabled.
    What confused me was that Clicks on labels on the sub-form did work even though the sub-form was disabled.

    I think I will mark this thread as solved, and thanks to all those who have replied.

    It is still a work around though, as what I really wanted was to have one Command Button on the main form overlaying the sub-form, but it seems you cannot overlay a sub-form with a command button (or anything else I think).
    Now I have two transparent buttons on the sub-form, one covering the header section and one covering the detail section. So, I can now respond to clicks anywhere on the sub-form.

    Searching the internet, I see that someone else had this very same problem back in 2010.

  15. #15
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Can set in your profile to send email notification when there are replies to any and all threads you are subscribed to or can set this with specific thread in the Advanced post editor.
    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.

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

Similar Threads

  1. Replies: 21
    Last Post: 01-31-2022, 01:09 PM
  2. Replies: 1
    Last Post: 09-12-2014, 06:09 AM
  3. Replies: 13
    Last Post: 03-09-2014, 02:11 AM
  4. Replies: 4
    Last Post: 10-08-2012, 05:33 PM
  5. Command Button Problem is Subform
    By Lupson2011 in forum Access
    Replies: 3
    Last Post: 08-25-2011, 08:39 AM

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