Results 1 to 6 of 6
  1. #1
    WendellS is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Aug 2016
    Posts
    10

    Hide a command button

    I thought this would be simple but I can’t figure it out. On a form I have a command button (the button is just a macro to print a report) and I call it “printericon” . but I want the printericon button to be hidden if the amount of records in the subform is greater than 36. I have done a macro with the IF statement with the setproperty function and it won’t work.
    Here is what I wrote
    If (count([material])<36)
    Setproperty
    Printericon
    Visible
    True
    ELSE
    Setproperty
    Printericon
    Visible
    False

    I put this macro under “After update” of a search box I had on the form. So if the search box changes this would fire off the macro to set the printer icon to be invisible or visible. But it’s NOT what am I doing wrong ?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    Do you get error message?

    Search box is on main form?

    Button is on main form?

    You need to count records of subform?

    [material] is field on subform?
    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
    WendellS is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Aug 2016
    Posts
    10
    Hello June
    Thanks for responding
    I do not get an error message
    And the the answer is YES to all the other questions

  4. #4
    WendellS is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Aug 2016
    Posts
    10
    June one more thing
    I even did this I created “dummy” buttons
    One for visible and another for invisible
    And after I did my search I would click on one of those dummy buttons and it would take 2-3 clicks for it to work to make the printericon to go invisible or appear.

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    I am surprised there is no error message.

    Code on main form referencing field/control on subform must reference through the subform container control: Forms!mainform!subformcontainer.Form.material

    Also can't use an aggregate function that way. Aggregate functions must be used within a query or in a textbox. Domain aggregate functions (DCount, DSum, DLookup) can be used in other areas of Access.

    Suggest you have a textbox on subform that calculates the count: =Count("*"). Then your code will reference that control.

    I don't use macros, only VBA.
    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.

  6. #6
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    It would be very easy if you used VBA instead of a macro
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

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

Similar Threads

  1. Hide command button on form from certain users
    By Delfina in forum Programming
    Replies: 5
    Last Post: 02-16-2019, 08:06 PM
  2. Hide command button on form from certain users
    By Delfina in forum Programming
    Replies: 9
    Last Post: 02-09-2019, 07:36 PM
  3. Replies: 1
    Last Post: 10-27-2016, 10:51 PM
  4. Replies: 2
    Last Post: 06-06-2012, 10:53 AM
  5. Replies: 1
    Last Post: 07-27-2010, 02:27 PM

Tags for this Thread

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