Solved

Inset into statement

Posted on 2013-11-05
5
196 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 119

Expert Comment

by:Rey Obrero
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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
No matter the version of Windows you are using, you may have some problems with Windows Search running too slow or possibly not running at all. Before jumping into how you can solve this issue, just know there are many other viable alternative deskt…
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

910 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now