Pesky Parameter boxes on SQL Append queries in VBA

wildsyp

Registered User.
Local time
Today, 19:55
Joined
Oct 15, 2008
Messages
19
Hi,

I have been trying to run a fairly straightforward but of VBA code to append four fields from a form into a table. Unfortunately, when the code runs through I get the 'Enter Parameter Value' box appear for the updatedby and changereason updates. This is very frustrating, but I am probably missing something simple. Code is below.

Any help with this would be great.

Cheers
Paul


date1 = Date
updatedby = fOSUserName
Change = Me.MIRef
changereason = InputBox("Please confirm reason for change to revised date")
DoCmd.RunSQL "INSERT INTO Tbl_RevisedEndDateChange ( [Updated By], Change, [Date Changed], [Reason for change] ) " & _
"Select " & updatedby & ", " & Change & ", " & Format(date1, "dd/mm/yyyy") & ", " & changereason & ";"
 
Presuming they are text data types, you need to surround the value with single quotes:

"Select '" & updatedby & "',...
 
Presuming they are text data types, you need to surround the value with single quotes:

"Select '" & updatedby & "',...

Solved! Thanks for your help.

Paul
 
No problemo; generally you have to surround text values with the single quote, date values with #, numeric values with nothing.
 
It all makes sense now. The # around dates has also resolved another niggling issue I have always had as well!
 

Users who are viewing this thread

Back
Top Bottom