Link to home
Start Free TrialLog in
Avatar of Denthion
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
ASKER CERTIFIED SOLUTION
Avatar of Paul Jackson
Paul Jackson
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
change this line

strBlendSor = "Insert into BlendSor ([ID])" & strBle

with

strBlendSor = "Insert into BlendSor ([ID]) Values(" & strBle & ")"
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 & ")"
Avatar of Denthion
Denthion

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.