Append queries in vb

beckyr

Registered User.
Local time
Today, 09:52
Joined
Jan 29, 2008
Messages
35
I was wondering how you get the value of a variable into a table that is being appended to. Ive tried the code below but the syntax is wrong. Im trying to get the variable replacedate into the OTH_RETIRE_DATE column

strsql = "Insert into [tblOther Staff]( OTH_FORENAME, OTH_SURNAME, OTH_DP_NO, OTH_FAC_NO, OTH_EMAIL, OTH_PAST,OTH_RETIRE_DATE)"
strsql = strsql & "Select tblTutor.TU_FORENAME, tblTutor.TU_SURNAME, tblTutor.TU_DP_NO, tblTutor.TU_FAC_NO, tblTutor.TU_EMAIL, True as Pastval,replacedate "
strsql = strsql & "From [tblOther Staff], [tblTutor]"
strsql = strsql & "Where tblTutor.[TU_CODE] = " & "'" & retiring & "'"
db.Execute (strsql)
 
You have to concatenate the value in, much the same as the value in the WHERE clause:

...Pastval, #" & replacedate & "#..."

(date values need to be surrounded by #)
 
Thank you - i wasnt sure of the syntax
 

Users who are viewing this thread

Back
Top Bottom