Results 1 to 4 of 4
  1. #1
    Seiquo's Avatar
    Seiquo is offline Advanced Beginner
    Windows 10 Access 2013 32bit
    Join Date
    May 2017
    Location
    Quebec
    Posts
    44

    Hide button if field in selected record contains specified text

    Hello all,

    So... I have a subform in continuous form view. I also have a button in the subform header that allows a second form (inspection form) to open according to the selected record in the subform. (I did not want to have a button on each "row" or record, and still don't want it ).

    Here are the codes (found on internet) that I use:

    Button code:

    Code:
    Private Sub Button_Click()
    'Get the ID
        Dim id_ As Integer
            id_ = Me.IDInspection
        'Open the new form and pass the ID to the .OpenArgs
        DoCmd.OpenForm "Fm_Directives1", acNormal, , , acFormPropertySettings, acWindowNormal, id_
    End Sub
    Load form code:

    Code:
    Private Sub Form_Load()
        With Me
            If Not IsNull(.OpenArgs) Then
                .Filter = "[IDInspection]=" & .OpenArgs
                .FilterOn = True
                .Caption = "IDInspection: " & .OpenArgs
            End If
        End With
    End Sub
    So far so good.

    Now, what I really would like is, if user selects a record in which the Inspection control (TxtInspection) value is "Stickers", then the button in the header should be hidden or deactivated in order to prevent said user to issue a useless report (because there can't be any inspection report when you just put a sticker on the Equipment). And I know for a fact that there are going to be mistakes made in that field, believe me...

    I'm stuck here... Thank you in advance for your help!

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,412
    in the subform current event put

    me.yourbuttonname.visible=txtInspection<>'Stickers '

  3. #3
    Minty is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    In the OnCurrent Event of the subform put something like

    Code:
    Me.cmdYourButton.Enabled = True
    If Me.txtInspection="Stickers" Then Me.cmdYourButton.Enabled = False
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  4. #4
    Seiquo's Avatar
    Seiquo is offline Advanced Beginner
    Windows 10 Access 2013 32bit
    Join Date
    May 2017
    Location
    Quebec
    Posts
    44
    WOW !

    Minty, your solution rocks. Thank you so much.

    Ajax, I get an error message with yours about a value that is null somewhere. Since Minty's solution works, I will not investigate any further, but thank you too anyway.

    Cheers!

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

Similar Threads

  1. Hide text untill click of a button
    By CHEECO in forum Access
    Replies: 1
    Last Post: 12-26-2017, 07:45 PM
  2. Show & Hide Text Box with a Button
    By aamer in forum Access
    Replies: 3
    Last Post: 07-30-2016, 09:40 PM
  3. Replies: 4
    Last Post: 02-19-2016, 10:17 AM
  4. Replies: 2
    Last Post: 09-11-2014, 11:37 PM
  5. Making a toggle button hide a text box.
    By RemonKoybito in forum Forms
    Replies: 3
    Last Post: 05-20-2011, 11:34 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