Results 1 to 9 of 9
  1. #1
    chris.williams is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2011
    Posts
    94

    Clearing a Date field

    I am having some difficulty clearing a date field.



    The form issue a "certificate" and the date the certificate was issued. I have a button on the form to clear a certificate if issued in error.

    I am attempting to clear the date field through

    [CertDate] =""

    but am unable to due to the date type not accepting a null value. The error I get is:

    "You tried to assign the Null value to a variable that is not a Variant data type."

    Any help is appreciated...

    Thx

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,600
    The "" is not a null, it is empty (zero length) string. Date/time data type field cannot have empty string. Don't know why the error message references null. Maybe that's just the best message statement Access can offer for the error.

    Try:

    [CertDate] = Null
    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.

  3. #3
    chris.williams is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2011
    Posts
    94
    Thank you. Tried that already. Didn't work for some reason. I got the same error.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,600
    Then don't know why having issue.

    Is CertDate also name of textbox on the form?

    I give bound controls a name different from field name. Often I refer to the control name instead of field name. Example from my code: Me.tbxDateEnter = Null
    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
    chris.williams is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2011
    Posts
    94
    It was, I changed the text box to have a different name than the field. Unfortunately, I get the same error.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,600
    Since can't replicate the issue, will have to anlayse your db and code. If you want to provide, follow instructions at bottom of my post.
    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.

  7. #7
    chris.williams is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2011
    Posts
    94
    The data is in a MySQL db, not in Access - do you still have the resources to receive and diagnose it?

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,600
    Sorry, no I do not have any flavor of SQL. So the problem is with MySQL, not Access?
    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.

  9. #9
    chris.williams is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2011
    Posts
    94
    While I have yet to confirm the issue is resolved, I believe the you led me to the answer. Those fields were marked as NN or Not Null in the db. I changed them and was able to manually clear the fields, but have yet to test the functionality from the Access app. Thank you

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

Similar Threads

  1. Replies: 2
    Last Post: 03-31-2012, 07:53 AM
  2. Clearing a Form
    By dabatman in forum Forms
    Replies: 4
    Last Post: 01-20-2012, 11:51 AM
  3. Clearing a boolean flag
    By accessnewb in forum Programming
    Replies: 14
    Last Post: 08-12-2011, 07:54 AM
  4. clearing a form
    By macsterling in forum Forms
    Replies: 0
    Last Post: 07-31-2008, 10:38 AM
  5. Clearing the clipboard with VBA?
    By Simon Sweet in forum Programming
    Replies: 1
    Last Post: 04-17-2008, 03:16 PM

Tags for this Thread

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