Results 1 to 4 of 4
  1. #1
    bytreeide is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    47

    Simplify VBA Code

    I am just wondering if there is some way to simplify the way that code looks. I have a CHECK BOX that toggles several controls from Visible to Not-Visible and I the code that I have written looks something like:

    If Condition A then Condition B1
    If Condition A then Condition B2
    If Condition A then Condition B3


    If Condition A then Condition B4
    If Condition A then Condition B5
    If Condition C then Condition D1
    If Condition C then Condition D2
    If Condition C then Condition D3
    If Condition C then Condition D4
    If Condition C then Condition D5

    Is there some way that I could simplify this to two lines? Like this:

    If Condition A then Condition B1 & Condition B2 & Condition B3 & Condition B4 & Condition B5
    If Condition C then Condition D1 & Condition D2 & Condition D3 & Condition D4 & Condition D5

    I just need to know if this is possible, if so, what is the syntax? I tried using "And" to make this happen and it only recognized the first condition.

    Thanks for your help

    bytreeide

  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
    Might help to see the actual code, but how about

    Code:
    If Condition A then 
      Condition B1
      Condition B2
      Condition B3
      Condition B4
      Condition B5
    End If
    I don't normally use the one-line format of If/Then, but this may work

    If Condition A then Condition B1 : Condition B2 : Condition B3 : Condition B4 : Condition B5
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    bytreeide is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    47
    Thanks for the suggestions

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    No problem.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 1
    Last Post: 04-01-2014, 10:33 AM
  2. Replies: 4
    Last Post: 02-11-2014, 05:37 PM
  3. Help To Simplify My Code
    By graviz in forum Programming
    Replies: 2
    Last Post: 09-11-2013, 07:58 PM
  4. Replies: 1
    Last Post: 05-04-2013, 12:19 PM
  5. Need help to simplify this process
    By shanea.kr in forum Access
    Replies: 1
    Last Post: 07-10-2012, 01:40 PM

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