Results 1 to 7 of 7
  1. #1
    vojinb is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jul 2011
    Posts
    18

    cannot update date in table

    Hy,
    I have a table having one date field formatted as short date "15.12.2011", and on a form text box formatted as short date format. When I click on text box calendar appears and I choose proper date, but when I want to update date in table via query it returns error.


    My query looks like:
    CurrentDb.Execute ("UPDATE category SET date=" & Forms![main form]!txtDate.Value)
    I don't see anything wrong but it keeps me returning error

    And If I use US format update works but with date 31.12.1899

  2. #2
    hertfordkc is offline 18 year novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    481

    Maybe...

    Quote Originally Posted by vojinb View Post
    Hy,
    I have a table having one date field formatted as short date "15.12.2011", and on a form text box formatted as short date format. When I click on text box calendar appears and I choose proper date, but when I want to update date in table via query it returns error.
    My query looks like:
    CurrentDb.Execute ("UPDATE category SET date=#" & Forms![main form]!txtDate.Value&"#")
    I don't see anything wrong but it keeps me returning error

    And If I use US format update works but with date 31.12.1899
    I'm guessing that txtDateValue is a 'string' rather than a 'date'.

  3. #3
    vojinb is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jul 2011
    Posts
    18
    Hi,
    txtDateValue is date formatted. In format properties of text field I choose short date (as in database table) and calendar appears from side of control .

  4. #4
    hertfordkc is offline 18 year novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    481
    Did you notice the change that I suggested for your code?

  5. #5
    vojinb is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jul 2011
    Posts
    18
    Quote Originally Posted by hertfordkc View Post
    Did you notice the change that I suggested for your code?
    Hi, did not till now ). Tried also with # but without success

  6. #6
    hertfordkc is offline 18 year novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    481
    Suggest you debug.print or otherwise check the value of 'txtdate.value'

  7. #7
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529

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

Similar Threads

  1. How can the date update itself?
    By amanda.ngan in forum Access
    Replies: 1
    Last Post: 11-25-2011, 01:20 AM
  2. Update date
    By BorisGomel in forum Forms
    Replies: 5
    Last Post: 09-20-2011, 03:15 PM
  3. query to update a date based on another date
    By tkendell in forum Access
    Replies: 3
    Last Post: 06-29-2011, 09:32 PM
  4. Replies: 1
    Last Post: 01-22-2011, 12:23 PM
  5. Update field in table after update on a subform
    By jpkeller55 in forum Queries
    Replies: 3
    Last Post: 09-30-2010, 08:02 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