473,398 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Run time error '3075': Syntax error (missing operator) in query expression

hello,

I'm trying to get my list box database to open up another form that contains more information on the selected record. I can get it to open the form just fine, but it always opens o the first record, rather than the one I have selected.

My error message is: Run-time error '3075': Syntax error (mising operator) in query expression 'Serial Number = 7632-562'.

All my records in the database are made up numbers and letters, as I am just testing it out now before using real entries.

My code is:

Expand|Select|Wrap|Line Numbers
  1. Private Sub SearchList_DblClick(Cancel As Integer)
  2.  
  3.     DoCmd.OpenForm "frmInfo", acNormal, , "Serial Number = " & Me![SearchList].Value
  4.  
  5. End Sub
the listbox is called Search List, and the form i want to open is called frmInfo.

Thanks to anyone with advice!
Jun 3 '19 #1

✓ answered by twinnyfo

Square braces around your field name.
Expand|Select|Wrap|Line Numbers
  1. Private Sub SearchList_DblClick(Cancel As Integer)
  2.  
  3.     DoCmd.OpenForm "frmInfo", _
  4.                    acNormal, , _
  5.                    "[Serial Number] = '" & Me.SearchList & "'"
  6.  
  7. End Sub
You had a space in your Field Name, which you should try to avoid in the future, to avoid such errors.

Hope this hepps.

8 3270
DJRhino1175
221 128KB
If it was me, I would put in the query of the form under the serial column:

Like[Enter Serial No.]

And have your code just open the form.
Jun 3 '19 #2
@DJRhino1175
I have a textbox up at the top that is used for searching through the databse by serial number, and the results are displayed in the listbox, so I though the best idea was to be able to click on one of the records in the listbox and just have that one come up.
Jun 3 '19 #3
twinnyfo
3,653 Expert Mod 2GB
It appears the issue is that you are searching for a record that has a text serial number, but using the syntax for a numeric value. Just because a "Serial Number" looks like numbers, it is not necessarily numeric (notice that there is a dash in your Serial Number).

Try this:

Expand|Select|Wrap|Line Numbers
  1. Private Sub SearchList_DblClick(Cancel As Integer)
  2.  
  3.     DoCmd.OpenForm "frmInfo", _
  4.                    acNormal, , _
  5.                    "Serial Number = '" & Me.SearchList & "'"
  6.  
  7. End Sub
Also note, there is no need to refer to the "value" of the control, as the Value is the default reference.

Hope this hepps!
Jun 3 '19 #4
@twinnyfo
Hey thanks for you response! I didn't think about it that way, good insight. I copied and pasted the code you gave me into access but i still got the same error, can you think of a reason why that would happen?
Jun 3 '19 #5
twinnyfo
3,653 Expert Mod 2GB
Square braces around your field name.
Expand|Select|Wrap|Line Numbers
  1. Private Sub SearchList_DblClick(Cancel As Integer)
  2.  
  3.     DoCmd.OpenForm "frmInfo", _
  4.                    acNormal, , _
  5.                    "[Serial Number] = '" & Me.SearchList & "'"
  6.  
  7. End Sub
You had a space in your Field Name, which you should try to avoid in the future, to avoid such errors.

Hope this hepps.
Jun 3 '19 #6
@twinnyfo
Works perfectly! thank you!
Jun 3 '19 #7
twinnyfo
3,653 Expert Mod 2GB
Glad I could be of service. Let us know if you need any more hepp!
Jun 3 '19 #8
NeoPa
32,556 Expert Mod 16PB
Twinny has already answered perfectly adequately but it may help to have a look at Quotes (') and Double-Quotes (") - Where and When to use them for a fuller understanding.
Jun 3 '19 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: alexz | last post by:
valuA = (request.form("toadd")) If valuA = "" then SQL = "UPDATE CourseReg SET attended='Active' WHERE ID IN("&request.form("toadd")&")" Set RS = MyConn.Execute(SQL) End If MyConn.Close Set...
1
by: chug | last post by:
I'm not a programmer but it's my job to solve this. Can someone help me with this error message? Microsoft OLE DB Provider for ODBC Drivers error '80040e14' Syntax error (missing operator)...
1
by: Justin R | last post by:
Hey I am really stuck and can't figure out what is wrong here is the code line and surrounding code, if anyone can help i would appreciate it. Thanks This first line is the line that has a problem...
4
by: srinathvs | last post by:
Hi, I have an access db that I am trying to query from a vb6 program. I've the following code: Dim sSQLQuery As String sSQLQuery = "SELECT * FROM TblData WHERE ID = " & Chr(39) & ID &...
7
by: 3c4j5d | last post by:
I am having difficulty in adding an additional table to a SQL statement. Basically, I want to add that the INSERT should take place if not found in this additional table. I will attach a file...
3
by: Bennett72 | last post by:
Hello - I'm getting a run time error 3075 (missing operator) in my query expression and cannot seem to determine why. I cut a snippet of code (see below) and ran the statement in a sql query view...
1
by: sushma somesh | last post by:
HI, my code for search is rec.Open "select * from Body_Markings_new where Part Number like '%" & txtsearch.Text & "%' ", conn, adOpenDynamic, adLockOptimistic after compiling this code getting...
2
by: pptechs | last post by:
Hello. In dying need of assistance. All I am trying to do is search a table for a valid user ID for a form login screen and I am getting error : "Run-time error 3075 syntax error (missing...
1
by: Vasago | last post by:
I have narrowed it down to .Driver) =" & Me!. My employees do have a comma in their names. Thank you for your help. Error Code says: Run-time error '3075' Syntax error(comma) in query...
3
by: irenenys | last post by:
Below is my code. Highlighted error is DoCmd.ApplyFilter task (Line #19) Not too sure what is wrong, really new to access programming. Option Compare Database Private Sub SearchB_Click() '...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.