Results 1 to 7 of 7
  1. #1
    TinaCa is offline Advanced Beginner
    Windows Vista Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    87

    Data Validation error on Update - date field

    I am trying to update the date field in a table (with the current date as the invoice date). When I run the VBA code I get a data validation error. I checked the talbe and the field is a date format. i even set it to short date and still get the error. Here's the update code

    InvDt = Date

    DoCmd.RunSQL "UPDATE CompanyInformation " _
    & "LEFT JOIN tblCompanyExtras ON CompanyInformation.CompanyAccountNo = tblCompanyExtras.CompanyId " _
    & "SET tblCompanyExtras.DateBilled = #" & InvDt & "# " _


    & "WHERE (((CompanyInformation.CompanyBillingDate) = " & BillDt & ") AND ((tblCompanyExtras.DateBilled) Is Null));"

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,622
    BillDt and InvDt are fields or variables?

    I presume CompanyBillingDate is a Date field, need the # delimiters.

    This date is saved in two tables?
    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
    TinaCa is offline Advanced Beginner
    Windows Vista Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    87
    BillDt is an integer, InvDt is a date

    I companybillingdate is integer, even if it was a date I have other update and insert queries containing date fields from one table to another and they are running without #'s.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,622
    Are BillDt and InvDt declared variables?
    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
    TinaCa is offline Advanced Beginner
    Windows Vista Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    87
    Yes, of course.

  6. #6
    TinaCa is offline Advanced Beginner
    Windows Vista Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    87
    Ok first mistake it was trying to update the wrong table I think. I need to update the tblCompanyExtras not CompanyInformation. Now I am getting a syntax error...errrr

    DoCmd.RunSQL "UPDATE tblCompanyExtras " _
    & "JOIN tblCompanyExtras ON CompanyInformation.CompanyAccountNo = tblCompanyExtras.CompanyId " _
    & "SET tblCompanyExtras.DateBilled = " & InvDt & " " _
    & "WHERE (((tblCompanyExtras.DateBilled) Is Null) AND ((CompanyInformation.CompanyBillingDate)= " & BillDt & "));"

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,622
    Maybe need the # delimiters for the date variable. Is InvDt explicitely declared as a Date type?
    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.

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

Similar Threads

  1. BUG! Field level date validation
    By buj in forum Forms
    Replies: 0
    Last Post: 09-16-2010, 08:23 PM
  2. Data validation warning vs error
    By mafrank101 in forum Access
    Replies: 3
    Last Post: 07-14-2010, 05:05 PM
  3. Replies: 7
    Last Post: 11-22-2009, 02:38 PM
  4. Print custom date for data validation
    By TheFuzzball in forum Database Design
    Replies: 2
    Last Post: 10-26-2009, 06:48 AM
  5. Field Level Date validation
    By fadone in forum Forms
    Replies: 1
    Last Post: 12-09-2005, 10:23 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