Results 1 to 3 of 3
  1. #1
    Chrtalgo is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2018
    Posts
    8

    SQL string works in query but not as CurrentDB.Execute "...

    Hi!


    I am trying to keep a record of movements.
    I have a button that changes the yes/no button on a record in the table InnUtmeldinger. At the same time I want to keep a log of every time the status is changed on a separate table called InnUtmeldinger. This SQL seems to work from a query, but not from VBA.

    The code should insert the active ID (Primary key) of the record that is being changed in the form Medlemsregister, along with todays date, into InnUtMeldinger.



    Code:
    currentdb.Execute "INSERT INTO InnUtmeldinger ( ID, Innmeldt ) SELECT Medlemsarkiv.ID, Date() FROM Medlemsarkiv WHERE (((Medlemsarkiv.ID)=[Forms]![Medlemsregister]![ID]));"
    I am getting error 3060 "Too few parameters. Expected 1"




    Any suggestions?

    Run as SQL is not the option I am looking for, as it will give a warning and I don't want to turn warnings off.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,901
    Currentdb.Execute "INSERT INTO InnUtmeldinger (ID, Innmeldt ) VALUES(" & Me!ID & ", Date())"
    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
    Chrtalgo is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2018
    Posts
    8
    Quote Originally Posted by June7 View Post
    Currentdb.Execute "INSERT INTO InnUtmeldinger (ID, Innmeldt ) VALUES(" & Me!ID & ", Date())"
    Love it, thank you!

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

Similar Threads

  1. RunSQL vs. QueryDef.Execute vs. CurrentDB.Execute
    By caubetiep1337 in forum Queries
    Replies: 8
    Last Post: 12-16-2015, 05:35 PM
  2. Error in CurrentDb.Execute
    By Stefan Moser in forum Access
    Replies: 5
    Last Post: 04-17-2015, 01:38 PM
  3. vba code help - Currentdb.execute
    By joycesolomon in forum Programming
    Replies: 5
    Last Post: 08-11-2014, 11:25 AM
  4. Problems with CurrentDb.Execute "UPDATE
    By GraeagleBill in forum Programming
    Replies: 4
    Last Post: 04-06-2013, 03:21 PM
  5. Update sql using currentdb.execute
    By laavista in forum Access
    Replies: 13
    Last Post: 08-15-2011, 03:51 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