Access Runtime Error 3075 Syntax Error
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow
Access Run Time Error 3075 Syntax Error Missing Operator
the company Business Learn more about hiring developers or posting ads with us Stack Overflow ms access runtime error 3075 Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of access vba runtime error 3075 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Runtime 3075 Syntax error up vote 2 down vote favorite I'm trying to build an ordering system in
Run Time Error 3075 Syntax Error In Query Expression
the style of northwind in access 2010 but slightly less complicated! I need to bring the price of the product from the inventory to the order details subform when the product is selected from the combo box, so being a novice my code isn't working properly... Private Sub Product_AfterUpdate() Dim PriceX As Currency, UnitX As Currency PriceX = DLookup("Unit Price", "ProductInventory", "[ProductInventory].[Product]=" & [Product].Value) UnitX = DLookup("Unit", "ProductInventory", "[Product] =" & [Product].Value) Unit_Price.Value
Run Time Error 3075 Syntax Error (comma) In Query Expression
= PriceX Unit.Value = UnitX End Sub ms-access access-vba ms-access-2010 share|improve this question edited Aug 23 '13 at 15:51 HansUp 79.1k114371 asked Aug 21 '13 at 18:56 amatthews 1313 In the future, please give details about the error message. We aren't all as brilliant as @HansUp! –Smandoli Dec 30 '15 at 17:59 1 It's easy to be generous when the posted answer solved my problem. Happy 2016 to you. –Smandoli Dec 31 '15 at 4:00 add a comment| 1 Answer 1 active oldest votes up vote 4 down vote accepted I suspect the full text of the error message was "Syntax error (missing operator) in query expression 'Unit Price'." You're looking up a value in a field named Unit Price. Since the field name includes a space, enclose it in square brackets to eliminate the error. PriceX = DLookup("[Unit Price]", "ProductInventory", "[Product]=" & [Product].Value) If you get a different error after that one, please give us the full text of the error message and indicate which line in your code triggered the error. From the current error you reported, it seems [Product] is text instead of numeric data type. So add single quotes around the value in the last part of the DLookup expression. PriceX = DLookup("[Unit Price]", "ProductInventory", "[Product]='" & [Product].Val
+ Ask a Question Need help? Post your question and get tips & solutions from a community of 418,417 IT Pros & Developers. It's quick & easy. Run-time error 3075 - Syntax error in string in run time error 3075 missing operator dlookup query expression VB6/MS-access P: 3 srinathvs Hi, I have an access db that I am trying
Run-time Error '3075' Syntax Error (missing Operator) In Query Expression
to query from a vb6 program. I've the following code: Dim sSQLQuery As String sSQLQuery = "SELECT * FROM TblData WHERE ID = " run time error 3075 syntax error in string in query expression & Chr(39) & ID & Chr(39) ID here is equal to 1234567890 MsgBox sSQLQuery the msgbox says: SELECT * FROM TblData WHERE ID = '1234567890 Note that the quotation is missing at the end Set rs = db.OpenRecordset(sSQLQuery, dbOpenDynaset) Here http://stackoverflow.com/questions/18365498/runtime-3075-syntax-error I get the error: Run-time error '3075' Syntax error in string in query expression 'ID='1234567890'. Note that now there's a single quotes before ID (+ where's the rest of the sql string). As a note, ID is not a numeric field in the access database. Its in as a text-field. Now here's the biggie: this code works for me in my development PC and the query returns with the data in the db. This started happening on another laptop that I https://bytes.com/topic/visual-basic/answers/863578-run-time-error-3075-syntax-error-string-query-expression-vb6-ms-access installed this application on all of a sudden and I am unable to reproduce this on my PC. Any help is appreciated. Feb 13 '09 #1 Post Reply Share this Question 4 Replies Expert 5K+ P: 8,127 debasisdas the following code Expand|Select|Wrap|Line Numbers DimsSQLQueryAsString sSQLQuery="SELECT*FROMTblDataWHEREID='"&ID&"'" it never happens that the same code will give different output on the same or any other system. Feb 14 '09 #2 reply P: 3 srinathvs Hi. Thanks for replying. Chr(39) adds the quotation (') before and after ID. I also tried the quotation strings directly like you've suggested and i get the same result. I agree that the same code will not give different results on different PCs. But, isn't it a possibility that my dev PC has some dependencies satisfied that a piece of code works alright on my PC, and the other PC is missing those dependencies. I don't think that is the case with this specific problem that I am having, but I just wanted to float that thought out. Feb 14 '09 #3 reply Expert 5K+ P: 8,127 debasisdas Are you still getting the error after doing the way i suggested ? Feb 14 '09 #4 reply P: 3 srinathvs It turned out that the ID that was returned from the source was null terminated and hence the quotation char could not be added. Thanks for your responses. Feb 14 '09 #5 reply Message Cancel Changes Post you
be down. Please try the request again. Your cache administrator is webmaster. Generated Fri, 30 Sep 2016 06:15:11 GMT by s_bd40 (squid/3.5.20)