Results 1 to 5 of 5
  1. #1
    Oblio is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Aug 2013
    Posts
    50

    Unhappy if a not visible control on a single form = 1, Control 1 and 2 are not visible

    Hi.

    On a Single Form type named "f_t_Address_Details" I have a control named "txt_Categories_Level_1_ID" on a single tab named "Asset Details_Page"(but may add more tabs in the future just in case that matters).

    If the "txt_Categories_Level_1_ID"control = 1, I want the following two controls named "txt_MAC_Address" and "txt_IP_Address" to be visible, otherwise I want the them to be not visible.

    In the On Open event I tried the following VBA.

    Code:
    IIf(f_Asset_Details.Controls!txt_Categories_Level_1_ID = 1, f_Asset_Details.Controls!txt_MAC_Address.visible=true,f_Asset_Details.Controls!txt_MAC_Address.visible=False)
    but I just get a Compile Error: Syntax error" message.



    Can anybody assist me with this ?
    Click image for larger version. 

Name:	My Form and controls.png 
Views:	11 
Size:	269.7 KB 
ID:	50362

    Thank you so much for helping me out with this...

    Thanks,

    Oblio

  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,929
    That is not correct use of IIf() function.

    Use If Then Else structure.

    Or

    With Me
    .txt_MAC_Address.Visible = .txt_Categories_Level_1_ID = 1
    .txt_IP_Address.Visible = .txt_Categories_Level_1_ID = 1
    End With

    Or use Conditional Formatting to set Enabled/Disabled.
    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
    Gicu's Avatar
    Gicu is online now VIP
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    And you want to move the code from the Open event to the Current event of the form (and probably also reference it in the AfterUpdate event of the txt_Categories_Level_1_ID control if it is editable).

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  4. #4
    Oblio is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Aug 2013
    Posts
    50
    THANKS SO MUCH !!!!
    I will get it working and post... thanks very much June7

  5. #5
    Oblio is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Aug 2013
    Posts
    50
    Awesome !!! That is very kind of you to help... I will try your solution as well

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

Similar Threads

  1. Replies: 2
    Last Post: 03-09-2021, 05:52 PM
  2. Return to form and make a control visible
    By shylock in forum Access
    Replies: 9
    Last Post: 11-09-2018, 06:15 PM
  3. Replies: 16
    Last Post: 03-26-2015, 08:35 PM
  4. Replies: 12
    Last Post: 12-11-2012, 09:27 AM
  5. Replies: 3
    Last Post: 03-29-2012, 12:40 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