Results 1 to 12 of 12
  1. #1
    jlgray0127 is offline Competent Performer
    Windows 2K Access 2000
    Join Date
    Oct 2011
    Location
    Central Illinois
    Posts
    187

    Forms and Conditions

    I have the below code to Deactivate the referred to text boxes when the Check box is clicked. I also want to have it add "Inactive" as the value in that field. Any thoughts on how to do this?



    Private Sub Check284_AfterUpdate()
    If [A4].Visible = True Then
    [A4].Visible = False
    Else
    [A4].Visible = True
    End If
    If [A16].Visible = True Then
    [A16].Visible = False
    Else
    [A16].Visible = True
    End If

  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
    [A4] = "Inactive"
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    jlgray0127 is offline Competent Performer
    Windows 2K Access 2000
    Join Date
    Oct 2011
    Location
    Central Illinois
    Posts
    187
    I am fairly new to doing this, so I am not sure where to put that statement, is really what I should have asked. lol
    Thank you for your quick response!

  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
    Wherever it logically fits. Along the lines of:

    If [A4].Visible = True Then
    [A4].Visible = False
    [A4] = "Inactive"
    Else
    ...

    Access will process the lines in order.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    jlgray0127 is offline Competent Performer
    Windows 2K Access 2000
    Join Date
    Oct 2011
    Location
    Central Illinois
    Posts
    187
    I can't seem to get it to work? It's not affecting the value of the field at all...

    I tried it in each line, for that cell, including, just adding it. The fields default value is set to "Empty". Would this affect it, maybe? I'm not sure. I'm getting pretty complicated with all the different things I have this form doing.

  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,641
    This should override the default value, so that's not it. I assume the visibility part is working? Try this

    Me.[A4] = "Inactive"

    using the name of the textbox, if it's not A4.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    jlgray0127 is offline Competent Performer
    Windows 2K Access 2000
    Join Date
    Oct 2011
    Location
    Central Illinois
    Posts
    187
    Still doesn't affect it. The Visibility portion is still working fine. Just won't change the value whether the box is checked or unchecked.
    It's like there should be an And statement in there or something? I'm not sure...

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    No, there doesn't need to be an "And" between the lines; Access will go line by line. Can you post the db here?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    jlgray0127 is offline Competent Performer
    Windows 2K Access 2000
    Join Date
    Oct 2011
    Location
    Central Illinois
    Posts
    187
    It worked. Moved the line up with the Me.A4 and it worked like a charm... It had to be placed as such... Just an FYI... thank you!

    Private Sub Check300_AfterUpdate()
    If [A12].Visible = True Then
    [A12].Visible = False
    Me.A12 = "Inactive"
    Else
    [A12].Visible = True

  10. #10
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    No problemo! Glad we got it sorted out.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  11. #11
    jlgray0127 is offline Competent Performer
    Windows 2K Access 2000
    Join Date
    Oct 2011
    Location
    Central Illinois
    Posts
    187
    In this scenario, I got it to go inactive as I was trying, but if they inadvertly click the wrong box, and unclick it, I need it to go back to the Default value of "Empty". Help!

  12. #12
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    In your Else clause:

    Me.A12 = ""
    or
    Me.A12 = Null
    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. Macros within Forms/Multiple Conditions
    By screwdrew1 in forum Forms
    Replies: 0
    Last Post: 04-11-2011, 01:28 PM
  2. Sum Column with conditions
    By g8rnc in forum Access
    Replies: 1
    Last Post: 06-10-2010, 09:59 AM
  3. if...then conditions ???
    By em07189 in forum Access
    Replies: 6
    Last Post: 03-05-2010, 10:29 PM
  4. Conditions / Expressions
    By Mark344 in forum Access
    Replies: 1
    Last Post: 02-19-2010, 08:15 AM
  5. Iff Statement Meeting 2 Conditions
    By newbie in forum Access
    Replies: 11
    Last Post: 06-11-2009, 11:59 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