Solved

Inset into statement

Posted on 2013-11-05
5
223 Views
Last Modified: 2013-11-11
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
0
Comment
Question by:Denthion
5 Comments
 
LVL 29

Accepted Solution

by:
Paul Jackson earned 500 total points
ID: 39625189
Your problem appears o be with the following as there is no operator in the where clause :

& "Where [BlendFix].[FPC-ID NUMBER] " & QSRJ1

Should it be :

& "Where [BlendFix].[FPC-ID NUMBER] =" & QSRJ1
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39625200
change this line

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

with

strBlendSor = "Insert into BlendSor ([ID]) Values(" & strBle & ")"
0
 
LVL 84
ID: 39625211
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 & ")"
0
 

Author Comment

by:Denthion
ID: 39625224
thank you all for your amazingly fast responses. I got it working thanks to Jacko72 I was missing an operator clause
0
 
LVL 31

Expert Comment

by:Helen_Feddema
ID: 39627743
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.
0

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question