Insert Into SQL Syntax (1 Viewer)

LanaR

Member
Local time
Tomorrow, 02:16
Joined
May 20, 2021
Messages
113
The following SQL works fine as a Query

Code:
StrSQL = "INSERT INTO TBL_TastNote ( WineID, AuthID, [Note] ) " & _
            "SELECT TBL_Wine.WineID, TBL_Wine.Wine, 4 AS Expr1, 'See Attatched PDF' AS Expr2 " & _
            "FROM TBL_Wine " & _
            "WHERE (((TBL_Wine.WineID)=[forms]![FRM_Wine]![WineID])); "

But causes the following error when implemented in VBA

1641660522554.png
 

jdraw

Super Moderator
Staff member
Local time
Today, 11:16
Joined
Jan 23, 2006
Messages
15,364
You are selecting 4 values and attempting to "INSERT" into 3 fields.
 

LanaR

Member
Local time
Tomorrow, 02:16
Joined
May 20, 2021
Messages
113
 

Gasman

Enthusiastic Amateur
Local time
Today, 15:16
Joined
Sep 21, 2011
Messages
14,056
Put the sql into a string variable and then debug.print that to see what you actually have, not what you think you have.
Then use that in the command when you get it correct.

if you still cannot see the error, then you can always post the output here ?
 

Users who are viewing this thread

Top Bottom