Results 1 to 4 of 4
  1. #1
    Kirsti is offline Competent Performer
    Windows 7 32bit Access 2003
    Join Date
    Jan 2012
    Location
    New Zealand
    Posts
    172

    Code Not Working

    Hi, I have a combo box in a form, where input is limited to a value list. I have the following code:



    Private Sub Field1_AfterUpdate()

    If ((Me.Field1) = "xxxx" Or (Me.Field1) = "yyyy") Then


    Me.Field2.Visible = True And Me.Field3.Visible = True And Me.Field4.Visible = True And Me.Field5.Visible = True And Me.Field6.Visible = True And Me.Field7.Visible = True And Me.Field8.Visible = True And Me.Field9.Visible = True


    Else


    Me.Field2.Visible = False And Me.Field3.Visible = False And Me.Field4.Visible = False And Me.Field5.Visible = False And Me.Field6.Visible = False And Me.Field7.Visible = False And Me.Field8.Visible = False And Me.Field9.Visible = False


    End If

    End Sub

    I use variations of this code often, and it always works, however I have never before tried it using a "xxxx" value (i.e. it has always been = True or IsNotNull etc).

    Is it possible to use this code in this way, and is there something I'm missing?

    Thanks,
    Kirsti

  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,641
    That should work, though I'd drop all the parentheses. The code to set should be

    Me.Field2.Visible = True
    Me.Field3.Visible
    = True

    rather than being separated by AND.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Kirsti is offline Competent Performer
    Windows 7 32bit Access 2003
    Join Date
    Jan 2012
    Location
    New Zealand
    Posts
    172
    Thanks Paul - it's now working perfectly.

  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,641
    Happy to help.
    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. Last Part of code not working
    By mejia.j88 in forum Programming
    Replies: 19
    Last Post: 02-22-2012, 12:36 PM
  2. VBA Code not working how it Should
    By Juan4412 in forum Programming
    Replies: 7
    Last Post: 12-07-2010, 01:59 PM
  3. VBA Code Not working
    By jo15765 in forum Programming
    Replies: 12
    Last Post: 12-03-2010, 04:01 PM
  4. VB code not working
    By cwwaicw311 in forum Programming
    Replies: 17
    Last Post: 04-26-2010, 07:02 PM
  5. VBA Code for working with IE
    By smikkelsen in forum Programming
    Replies: 3
    Last Post: 04-15-2010, 01:05 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