Results 1 to 9 of 9
  1. #1
    Jon1092 is offline Novice
    Windows 10 Office 365
    Join Date
    Apr 2020
    Posts
    6

    [Help] Button Visible

    Hi there,

    I am trying to do a script with a admin page. For example if I want to stop my team adding new customers I'm going to remove the new customer button on my form by using a table in another form. So if I want to hide button1 I will go into table3 and click the buttonvisable yes/no and it will hide on my other form. Im having problems with linking the button to the table.



    Here is a copy of the code.

    Dim SeeButton As String
    SeeButton = DLookup("ButtonVisible", "HomeScreenButtons", "ButtonVisible =", Me.GuestBut1)
    If SeeButton = Yes Then
    MsgBox "It can be seen"
    Else
    MsgBox "It cannot be seen"


    End If

    in the table is ID, Button Name, ButtonVisible, buttonenabled

    Im loosing my mind

    thank you in advance

    Jon

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Well, you're passing the "value" of the button, not the name. Perhaps

    Me.GuestBut1.Name

    or just pass a string.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Jon1092 is offline Novice
    Windows 10 Office 365
    Join Date
    Apr 2020
    Posts
    6
    I tried me.guestbut1.name i got a compile error with dlookup highlighted and a message of compile error: Wrong number of arguments or invalid propertu assignment.

  4. #4
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,974
    The filter criteria for your DLookup is incorrect. Replace the comma with an ampersand &.

    Also the following line looks wrong.
    As SeeButton is a string then you need to enclose Yes in quotes: "Yes"
    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

  5. #5
    Jon1092 is offline Novice
    Windows 10 Office 365
    Join Date
    Apr 2020
    Posts
    6
    Fixed the & and now getting run-time error '438': Object doesnt support this property or method

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I'll get out of the way.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,974
    Did you also modify the following line as suggested?
    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

  8. #8
    Jon1092 is offline Novice
    Windows 10 Office 365
    Join Date
    Apr 2020
    Posts
    6
    Yes I reread the comments again and I have got it working to a ok level just needs tweeking thank you for all your help guys

  9. #9
    accesstos's Avatar
    accesstos is offline Expert
    Windows XP Access 2007
    Join Date
    Dec 2018
    Location
    Greece
    Posts
    551
    Presuming that the data type of ButtonVisible is Yes/No, your original code could be:
    Code:
    Dim SeeButton As Boolean
    SeeButton = DLookup("ButtonVisible", "HomeScreenButtons", "[Button Name] ='" & Me.GuestBut1.Name & "'")
    If SeeButton Then
        MsgBox "It can be seen"
    Else
        MsgBox "It cannot be seen"
    End If
    and in actual script:
    Code:
    With Me.GuestBut1
        .Visible = DLookup("ButtonVisible", "HomeScreenButtons", "[Button Name] ='" & .Name & "'")
    End With

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

Similar Threads

  1. Replies: 5
    Last Post: 08-14-2017, 02:19 AM
  2. Replies: 1
    Last Post: 12-28-2013, 12:38 PM
  3. make fields visible onclick() button
    By rivereridanus in forum Programming
    Replies: 4
    Last Post: 06-25-2012, 11:08 PM
  4. Replies: 2
    Last Post: 01-06-2011, 04:38 AM
  5. Replies: 1
    Last Post: 09-27-2010, 04:27 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