Results 1 to 6 of 6
  1. #1
    rob0829 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Sep 2017
    Posts
    9

    Using Checkbox to clear field


    I've done some googling and I can't seem to find a way to get this to work:

    I have forms setup with checkboxes for different levels of Approval. When an approve checkbox is ticked it automatically populates the current date. I want to add a "Rework" checkbox where for example if Approver 1 approves and it records that date, then Approver 2 wants some rework to be done they can check the "Rework" box and it will clear the date recorded for Approver 1 to make the item appear back in their list. I can't seem to get the date to clear with the checkbox. This is what I have so far.

    *This part works* - Records date if Approver 2 approves
    Private Sub Approval2_AfterUpdate()
    If Me.Approval2 = True Then
    Me.Second_Approval = Date
    End If
    End Sub

    *DOES NOT WORK* - Doesn't clear the date that was recorded for Approver 1
    Private Sub Rework_AfterUpdate()
    If Me.Approval2 = True Then
    Me.First_Approval = Null
    End If
    End Sub

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    That is correct IF the TEXTBOX for the date field is called 'First_Approval'
    sometimes they have the same name as the field but not always.

    sometimes if you use field names with spaces you must use me.[
    First Approval] in brackets, but usu the underscore works too.

    note: DONT put spaces in your fieldnames.


  3. #3
    rob0829 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Sep 2017
    Posts
    9
    I've gone back and removed all the spaces in "First Approval" to make it "FirstApproval" however when I'm typing its still prompting me for "First_Approval" as seen in the screen. I've I remove the underscore I get an error, if I leave it it doesn't work.

    I should mention that this form is linked to a Query and then back to a table. I'd like to delete the date from the underlying table.
    Click image for larger version. 

Name:	Screenshot.jpg 
Views:	6 
Size:	77.7 KB 
ID:	30862

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,928
    Shouldn't that be:

    If Me.Rework = True Then


    You changed field names in table? Did you also change the textbox names to reflect the same? I always give bound controls a name different from the field, such as tbxSecApp
    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.

  5. #5
    Micron is online now Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    I've gone back and removed all the spaces in "First Approval" to make it "FirstApproval"
    Where? It looks like you didn't change it on the form itself as you seem to have a control with the old name. Me refers to the form. Me.Something, the Something refers to an object on the form. It isn't a reference to any underlying table or query field name. Using a form wizard will create controls with the same names as fields, which IMHO is not a good thing. If I use a wizard, I immediately rename the controls as per conventional wisdom, which may differ slightly from other people's habit. FirstApproval might become txtFirstApproval or cmbFirstApproval, depending on what type the control is. Others like cbo for combo.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  6. #6
    rob0829 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Sep 2017
    Posts
    9
    Quote Originally Posted by June7 View Post
    Shouldn't that be:

    If Me.Rework = True Then


    You changed field names in table? Did you also change the textbox names to reflect the same? I always give bound controls a name different from the field, such as tbxSecApp
    Good eye! This was exactly my problem. I mistakenly wasn't pointing to the "Rework" checkbox.

    Thanks everyone!!

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

Similar Threads

  1. Replies: 1
    Last Post: 11-26-2014, 02:30 PM
  2. Select All/ Clear All checkbox
    By TheHarleygirl2005 in forum Forms
    Replies: 11
    Last Post: 01-15-2013, 03:21 PM
  3. Clear field
    By Fortfury in forum Forms
    Replies: 1
    Last Post: 12-28-2012, 08:20 PM
  4. clear checkbox and list box using TypeOf......Is
    By Chuck55 in forum Programming
    Replies: 13
    Last Post: 04-06-2012, 08:21 PM
  5. Search field will not clear
    By SemiAuto40 in forum Programming
    Replies: 1
    Last Post: 10-13-2011, 08:23 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