Results 1 to 6 of 6
  1. #1
    sk88 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Aug 2011
    Posts
    183

    'After update' Event procedure

    I have a question (Q1) in my form where if the staff chooses a 'NO' from a drop down menu, two other questions will appear (Q2 AND Q3.

    I have this code in 'after update'

    Code:
     
    Private Sub Combo817_AfterUpdate()
    
    
       If Me.Combo817.Value = "No" Then
       
       Me.Combo815.Visible = True
       Me.lasttimevisit_Label.Visible = True
       Me.Label820.Visible = True
       Me.Text819.Visible = True
      
      
       Else
       Me.Combo815.Visible = False
       Me.lasttimevisit_Label.Visible = False
       Me.Label820.Visible = False
       Me.Text819.Visible = False
        
    
       End If
    
    End Sub
    everything works fine except if the staff after answer to Q2 AND Q3 realizes that the answer for Q1 should be a YES, whatever the input was done in Q2 and Q3 does not get deleted and save it to my database.



    Is there a code for error checking or something where I can insert it here so that if the answer is YES, Q2 AND Q3 is cleared?

  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
    One of these should work:

    Me.Combo815 = Null

    Me.Combo815 = ""

    You'll find as you get better that giving controls meaningful names is a great help in the long run.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    sk88 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Aug 2011
    Posts
    183
    Quote Originally Posted by pbaldy View Post
    One of these should work:

    Me.Combo815 = Null

    Me.Combo815 = ""

    You'll find as you get better that giving controls meaningful names is a great help in the long run.

    Thanks pbaldy!

    but it is giving me error

    I put tried both of your codes.
    I insert it under ELSE IF

    Code:
    Private Sub Combo817_AfterUpdate()
    
    
       If Me.Combo817.Value = "No" Then
       
       Me.Combo815.Visible = True
       Me.lasttimevisit_Label.Visible = True
       Me.Label820.Visible = True
       Me.Text819.Visible = True
      
      
       Else
       Me.Combo815.Visible = False
       Me.lasttimevisit_Label.Visible = False
       Me.Label820.Visible = False
       Me.Text819.Visible = False
       Me.Combo815 = Null
       Me.Text819.Visible = Null
        
    
       End If
    
    
    End Sub

    where did I go wrong?

  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
    What error do you get? That last line is wrong, as you can't set the visible property to Null.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    sk88 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Aug 2011
    Posts
    183
    Quote Originally Posted by pbaldy View Post
    What error do you get? That last line is wrong, as you can't set the visible property to Null.

    it works now!! thanks pbaldy! I removed 'visible' from the line and it works just the way that I have wanted!

  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,521
    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. On-Click Event Procedure
    By tbassngal in forum Forms
    Replies: 6
    Last Post: 07-20-2011, 07:06 AM
  2. Replies: 1
    Last Post: 07-08-2011, 10:26 AM
  3. Replies: 4
    Last Post: 05-18-2011, 03:24 PM
  4. On Click Event Procedure
    By MrDean in forum Forms
    Replies: 3
    Last Post: 10-07-2009, 07:16 AM
  5. Troubleshoot NotInList Event Procedure
    By skyrise in forum Programming
    Replies: 4
    Last Post: 02-23-2009, 06:06 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