1

When attempting to insert a vba Date obtained from the Now function, I get the error:

"Wrong number of arguments or invalid property assignment"

Since I counted the parameters already I'm going to have to assume this has to do with trying to assign the date to the parameter v_logdate below:

Dim timeOfExecution As Date
timeOfExecution = Now
' ...

' INSERT a log record that says that this guy was 
Dim qdef1 As DAO.QueryDef
Set qdef1 = db.QueryDefs("InsertAllTimeSyncLogRecord")

With qdef
     ' ...set some other parameters
    .Parameters("v_logdate").Value = timeOfExecution ' timeOfExecution
     ' ...set some other parameters
End With

qdef1.Execute , dbFailOnError

My insert statement (InsertAllTimeSyncLogRecord) looks like this: In the AllTimeSyncLog table the LogDate field the parameter will be inserted into is a Date/Time type.

INSERT INTO AllTimeSyncLog ( 
   abradcwhash, hash, LogDate, firstname, lastname, 
   cohortid, email, department, [password], method, username 
)
VALUES (
    v_abradcwhash, v_hash, v_logdate, v_firstname, v_lastname, 
    v_cohortid, v_email, v_department, v_password, v_method, v_username
);

Is there some other way that I need to be assigning the timeOfExecution Date to the v_logdate parameter in my InsertAllTimeSyncLogRecord DAO.QueryDef?

3
  • 1
    You assign your saved query def to qdef1, but then you use qdef (without the trailing 1) in your with clause. Is this a typo translating to SO or the source of your problem? Commented Dec 6, 2013 at 19:45
  • when im inserting date from vba into sql server i usually format it like this before insertion '" & Format(Now, "yyyy-mm-dd hh:nn:ss") & "' Commented Dec 6, 2013 at 23:32
  • Are you using an external data source (e.g. SQL Server) or Access' built-in database engine (JET)? Which version of Access are you using? Commented Dec 13, 2013 at 14:31

1 Answer 1

1

It's also worth mentioning that in MS Access, you need to surround dates with pound signs (#) , though I'm not sure if that applies to querydef parameters, I would assume so.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.