Results 1 to 4 of 4
  1. #1
    anunat is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    19

    Problem with Update Command in Access

    I am trying to populate the SaleDate column in my table using the UPDATE command.

    Dim mydate As Date
    mydate = DateValue("01/" & strmonth & "/" & stryear)
    MsgBox ldate (shows date in mm/dd/yyyy format correctly)

    When I try to use mydate in the UPDATE statement, I get the error: too few arguments.

    CurrentDb().Execute "UPDATE 1 SET [SaleDate] = mydate;"



    Can somebody help me with this?

    If my method is completely wrong, can you please suggest how I can use a date variable in the UPDATE statement?

  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,652
    For starters, you're using 2 different variables, unless that's a typo. Second, you have to concatenate the variable, using the appropriate delimiter for date values:

    CurrentDb().Execute "UPDATE 1 SET [SaleDate] = #" & mydate & "#"

    Is your table really named 1?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    anunat is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    19
    Thanks so much. That worked.

    Yeah I am just playing around so did name my table 1.

  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,652
    Happy to help, and welcome to the site.
    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. Replies: 12
    Last Post: 03-14-2012, 10:54 AM
  2. Problem in MS Access data update
    By vinwin06 in forum Access
    Replies: 1
    Last Post: 02-17-2012, 12:53 PM
  3. Command Button Problem is Subform
    By Lupson2011 in forum Access
    Replies: 3
    Last Post: 08-25-2011, 08:39 AM
  4. Access Update with Join Problem
    By saascuba in forum Access
    Replies: 3
    Last Post: 11-03-2010, 01:20 PM
  5. Set command problem in legacy system
    By ch875299 in forum Programming
    Replies: 8
    Last Post: 02-02-2010, 04:59 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