Insert Into SQL Syntax (1 Viewer)

LanaR

Member
Local time
Today, 15:34
Joined
May 20, 2021
Messages
87
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, 01:34
Joined
Jan 23, 2006
Messages
14,317
You are selecting 4 values and attempting to "INSERT" into 3 fields.
 

LanaR

Member
Local time
Today, 15:34
Joined
May 20, 2021
Messages
87
 

Gasman

Enthusiastic Amateur
Local time
Today, 06:34
Joined
Sep 21, 2011
Messages
10,531
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