473,395 Members | 1,521 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,395 software developers and data experts.

Error 3075 missing operator in query expression

101 100+
Hope someone can help with a query expression. I am trying to open a form from a variable set in another form and have the following query set on button click:-

Expand|Select|Wrap|Line Numbers
  1. If Not Me.NewRecord Then
  2. DoCmd.OpenForm "frmChangeBooking", WhereCondition:="[BookLocation]=" & Me.Room
  3. End If
  4.  
I am getting a missing operator error but the syntax is exactly as shown in Acess 2010 Prigrammers Reference?.

I have Form A with a combo box to list Rooms and I want to open Form B to show records for the Room chosen by Form A. Have captured Me. Variable and this is fine.
Nov 4 '11 #1
7 4806
jimatqsi
1,271 Expert 1GB
The parameters to OpenForm in previous versions of Access are
(Form Name,
View Mode,
Filter Name,
Where Condition,
Form Mode,
Window Mode,
Open Args)

with everything but Form Name being optional. So I think you need at least one more comma after your form name; I'm not sure if "WhereCondition:=" is specifying the filter name or where condition, I suppose the latter, in which case you need 2 more commas inserted after form name.

Is "WhereCondition:=" actually part of the call? It doesn't look like any FormOpen I have ever done, but I have not been in Access 2010 yet. I would drop that literal and just put the condition itself.

Jim
Nov 4 '11 #2
Cyd44
101 100+
Hi jimatqsi

many thanks for the advise, I have managed to get this working by reverting to a query and calling the Filtername argument
Expand|Select|Wrap|Line Numbers
  1. If Not Me.NewRecord Then
  2. DoCmd.OpenForm "frmChangeBooking", FilterName:="qryShowbookingbyRoom"
  3.  
  4. End If
However, I looked at Context sensiteve Help for WhereCondition and it gives an example exactly how I had coded it originally. This example does not work for me.

Not to worry, I have got it working using Filtername.

many thanks for your advise and comments
Nov 4 '11 #3
NeoPa
32,556 Expert Mod 16PB
I cannot say positively what your problem was Cyd, but it wasn't the use of WhereCondition=. That's an example of named parameters and, though it's more typical to use all names in a call, it is possible to use named parameters after some positional ones. It's not possible to use any positional ones after a named one has been used. With named parameters the number of commas (,) is irrelevant.

I'm guessing the parameter passed included reference to a string value. If [BookLocation] is a string rather than a number then the code should have been :
Expand|Select|Wrap|Line Numbers
  1. If Not Me.NewRecord Then
  2.     DoCmd.OpenForm "frmChangeBooking", WhereCondition:="[BookLocation]='" & Me.Room & "'"
  3. End If
Of course, using FormName:="frmChangeBooking" would be even better and easier to read.

PS. I just reset the Best Answer as it was more of a question than an answer - and not really very near the mark on this one I'm afraid Jim.
Nov 11 '11 #4
jimatqsi
1,271 Expert 1GB
You're absolutely right, Ade. I have never seen passing parameters like that. I swear, after 10 years I still learn something new about Access nearly every day.

Thank you for your post, Cyd44, and for your illumination of this subject, NeoPa.

Jim
Nov 12 '11 #5
NeoPa
32,556 Expert Mod 16PB
I won't say it was a pleasure, as resetting another expert's answer is something I don't like to do, but if it helped illuminate this point then I'm certainly happier than I was ;-)

I always hated the idea of positional parameters with optionals missed out. Multiple commas seem to me a very poor, and easily confused, way of passing parameters. Named parameters can be cumbersome, so I don't use them all the time, but for when a call is obscure I like to use them. It adds clarity to the code I find.
Nov 12 '11 #6
Cyd44
101 100+
Thanks a lot guys. In the end I used a query to open the form by setting OpenForm "form" Filter = query

This works fine.

Thanks again guys
Nov 14 '11 #7
NeoPa
32,556 Expert Mod 16PB
That will work for you Cyd, but I'd recommend you use the WhereCondition approach going forward where possible.

Maintaining queries simply for handling something easily handled by a string in your code gives you extra work, leaves more disparate items in your database to maintain and is even less clear to understand when someone has to review or debug the project. It is also a more standard approach so whenever working with others (EG asking questions here on Bytes or discussing with a colleague) you are more likely to reach a common understanding and find communication easier (This translates to more experts who are able to help with a question).
Nov 14 '11 #8

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: JMCN | last post by:
I have an ftp program that i inherited and i tried to modify it to ftp over my file however, i receive an error message : run-time error '3075 syntax error (missing operator) in query expression...
3
by: william | last post by:
Hello Everyone, I'm using Access 2000. I entered the following code to do some data validation, however it is not working. I'm trying to ensure that the user cannot enter a duplicate inspection...
2
by: sfrvn | last post by:
I am embarrassed to say I cannot make this work. Recently upgraded to Access 2003, but do not know if that part of problem (AKA 'syntax change'). Would someone be kind enough to lead me by the...
0
by: Java25 | last post by:
I am trying to insert a date to my access database and i get the error below. please help: Syntax error in string in query expression ''Fri Jun 08 10:49:00 CAT 2007)'. I only want in the...
6
by: Nadnerb78 | last post by:
Please see code below: strSQL = "SELECT Max(EntryType) AS MaxOfEntryType " & _ "FROM tblForecastData GROUP BY BusinessLine, , Week " & _ "HAVING ((()='" & xx & "') AND ((Week)=" & xx & ")) " ...
5
by: Just_a_fan | last post by:
I tried to put an "on error" statement in a routine and got the message that I cannot user "on error" and a lamda or query expression in the same routine. Help does not list anything useful for...
3
by: shawnmiller77 | last post by:
Need Help ASAP! History: Installed new SBS 2003 server on Monday. Migrated IIS, website and current Access database over to new server. I did not develop the website or Access database. Former...
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 &...
5
by: rolltide | last post by:
I've seen many similar threads, but despite repeated efforts I cannot figure out my problem. I am running Access 2003, VB 6.5, Office XP Pro. Code excerpt is below (you can see where I've tried...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.