Assistance needed in sql syntax while breaking code into multiple lines

Though not required, I'd personally use a parameter driven insert.
Code:
Dim asSQL As String
asSQL = "Insert Into Tasks (" & _
    " Received," & _
    " Sender," & _
    " [Sent at]," & _
    " Employee," & _
    " Department)"
    
asSQL = asSQL & " SELECT p01, p02, p03,p04,p05"

    With CurrentDb.CreateQueryDef("", asSQL)
        .Parameters(0) = me.rvd
        .Parameters(1) = me.snd
        .Parameters(2) = me.sntat
        .Parameters(3) = me.emp
        .Parameters(4) = me.dpt
        .Execute
    End With

Biggest advantage is that you get ACCESS to worry about formatting dates and such. Also supports having single or double quotes in data.

Arnel posted a more elaborate function to do this, but I find it more intuitive when coding to spell it out so I won't forget what I'm doing.
 

Users who are viewing this thread

Back
Top Bottom