Denthion
asked on
Inset into statement
Please help me, having an issue with this bit of code. it keeps telling me missing operator in query expression. been trying to learn access on my own but this has me stumped. thank you
With Me!lbSelected
For Each varItem In .ItemsSelected
Select Case .Column(0, varItem)
Case Is <> " "
QSRJ1 = QSRJ1 & "'" & .Column(0, varItem) & "',"
strBle = "Select distinct [BlendMix].[BlendMix] " _
& "from [BlendMix],[BlendFix] " _
& "Where [BlendFix].[FPC-ID NUMBER] " & QSRJ1
' DoCmd.RunSQL "Delete from BledSor"
strBlendSor = "Insert into BlendSor ([ID])" & strBle
DoCmd.RunSQL strBlendSor
End Select
strList = strList & "'" & .Column(0, varItem) & "',"
Next varItem
End With
With Me!lbSelected
For Each varItem In .ItemsSelected
Select Case .Column(0, varItem)
Case Is <> " "
QSRJ1 = QSRJ1 & "'" & .Column(0, varItem) & "',"
strBle = "Select distinct [BlendMix].[BlendMix] " _
& "from [BlendMix],[BlendFix] " _
& "Where [BlendFix].[FPC-ID NUMBER] " & QSRJ1
' DoCmd.RunSQL "Delete from BledSor"
strBlendSor = "Insert into BlendSor ([ID])" & strBle
DoCmd.RunSQL strBlendSor
End Select
strList = strList & "'" & .Column(0, varItem) & "',"
Next varItem
End With
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Also, if FPC-ID Number is a Text field:
& "Where [BlendFix].[FPC-ID NUMBER] ='" & QSRJ1 & "'"
Also, there's no space between the (ID) and your subquery, and you might also need to enclose the subquery in parentheses in Access:
strBlendSor = "Insert into BlendSor ([ID]) (" & strBle & ")"
& "Where [BlendFix].[FPC-ID NUMBER] ='" & QSRJ1 & "'"
Also, there's no space between the (ID) and your subquery, and you might also need to enclose the subquery in parentheses in Access:
strBlendSor = "Insert into BlendSor ([ID]) (" & strBle & ")"
ASKER
thank you all for your amazingly fast responses. I got it working thanks to Jacko72 I was missing an operator clause
It helps to put in a Debug.Print statement to display a variable such as QSRJ1 in the Immediate Window, so you can quickly debug any problems with missing operators, etc. Or you can add a Watch for it.
strBlendSor = "Insert into BlendSor ([ID])" & strBle
with
strBlendSor = "Insert into BlendSor ([ID]) Values(" & strBle & ")"