473,699 Members | 2,278 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Syntax Error in Query Expression - Help

Please help - just take a quick look at the function code below. It
probably just needs some minor ["] tweaking.

The function module is based on an intermediate query to provide a
group record total from a subform that is posted to a field on the
main form. "Everything seems to work fine" except that I consistently
receive an error everytime I attempt to create a new record on the
main form. However, there are no errors received when accessing
existing records.

It is a Run-Time Error 3075 - Synax error (missing operator) in query
expression 'IDRef=' . And when opening the module, the following is
highlighted: Set rst = CurrentDb.OpenR ecordset(strSQL ). Here is the
code structure of the module:

Function GetTotalAdditio nal(IDRef) As Currency

Dim rst As Recordset, strSQL As String

strSQL = "Select TotalAdditional FROM qryAddCost WHERE IDRef = " &
IDRef

Set rst = CurrentDb.OpenR ecordset(strSQL )

If rst.RecordCount = 0 Then
GetTotalAdditio nal = 0

Else
GetTotalAdditio nal = rst![TotalAdditional]

End If

rst.Close
Set rst = Nothing

Exit Function

End Function
The text box Control Source (AddCost) on the main form uses:
=[Forms]![frmMain]![sfrmAdditionalC osts]![TotalAdditional Cost]

On the subform (continuous forms) the field name is
(TotalAdditonal Cost) and the Control Source is set to:
=GetTotalAdditi onal([IDRef])

The query (qryAddCosts) contains the IDRef as Group By and Total
Additional which is the sum of 3 groups of cost.

Based on the table (tblAdditionalC osts).

I have tried many different things, especially restructuring the code,
but to no avail. Any assistance will be greatly appreciated. Thanks.
Nov 12 '05 #1
8 17495
On 28 Sep 2003 04:36:11 -0700, ot***@safe-mail.net (Dalan) wrote:

strSQL = "Select TotalAdditional FROM qryAddCost WHERE IDRef = " &
IDRef


for a start this one should be:
strSQL = "Select qryAddCost.Tota lAdditional FROM qryAddCost WHERE
qryAddCost.IDRe f = " & IDRef & ";"
--
bebelino
Nov 12 '05 #2
If you've only got one table or query in the FROM section of the query,
there's no need to propagate that name throughout the query. And the
semicolon at the end is optional.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
"bebelino" <a.*@c.d> wrote in message
news:hq******** *************** *********@4ax.c om...
On 28 Sep 2003 04:36:11 -0700, ot***@safe-mail.net (Dalan) wrote:

strSQL = "Select TotalAdditional FROM qryAddCost WHERE IDRef = " &
IDRef


for a start this one should be:
strSQL = "Select qryAddCost.Tota lAdditional FROM qryAddCost WHERE
qryAddCost.IDRe f = " & IDRef & ";"
--
bebelino

Nov 12 '05 #3
I suspect that the function isn't getting a valid value for IDRef, so that
strSQL is only getting Select TotalAdditional FROM qryAddCost WHERE IDRef =,
with nothing else after the equal sign.

Have you got a text box IDRef on the subform that's bound to the query field
IDRef? If so, try renaming the text box to something different than the
field name (say to txtIDRef)

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
"Dalan" <ot***@safe-mail.net> wrote in message
news:50******** *************** ***@posting.goo gle.com...
Please help - just take a quick look at the function code below. It
probably just needs some minor ["] tweaking.

The function module is based on an intermediate query to provide a
group record total from a subform that is posted to a field on the
main form. "Everything seems to work fine" except that I consistently
receive an error everytime I attempt to create a new record on the
main form. However, there are no errors received when accessing
existing records.

It is a Run-Time Error 3075 - Synax error (missing operator) in query
expression 'IDRef=' . And when opening the module, the following is
highlighted: Set rst = CurrentDb.OpenR ecordset(strSQL ). Here is the
code structure of the module:

Function GetTotalAdditio nal(IDRef) As Currency

Dim rst As Recordset, strSQL As String

strSQL = "Select TotalAdditional FROM qryAddCost WHERE IDRef = " &
IDRef

Set rst = CurrentDb.OpenR ecordset(strSQL )

If rst.RecordCount = 0 Then
GetTotalAdditio nal = 0

Else
GetTotalAdditio nal = rst![TotalAdditional]

End If

rst.Close
Set rst = Nothing

Exit Function

End Function
The text box Control Source (AddCost) on the main form uses:
=[Forms]![frmMain]![sfrmAdditionalC osts]![TotalAdditional Cost]

On the subform (continuous forms) the field name is
(TotalAdditonal Cost) and the Control Source is set to:
=GetTotalAdditi onal([IDRef])

The query (qryAddCosts) contains the IDRef as Group By and Total
Additional which is the sum of 3 groups of cost.

Based on the table (tblAdditionalC osts).

I have tried many different things, especially restructuring the code,
but to no avail. Any assistance will be greatly appreciated. Thanks.

Nov 12 '05 #4
On Sun, 28 Sep 2003 12:34:36 GMT, "Douglas J. Steele"
<dj******@canad a.com> wrote:
If you've only got one table or query in the FROM section of the query,
there's no need to propagate that name throughout the query. And the
semicolon at the end is optional.


didn't know that. Thanks,
--
bebelino
Nov 12 '05 #5
bebelino <a.*@c.d> wrote in
news:2t******** *************** *********@4ax.c om:
On Sun, 28 Sep 2003 12:34:36 GMT, "Douglas J. Steele"
<dj******@canad a.com> wrote:
If you've only got one table or query in the FROM section of
the query, there's no need to propagate that name throughout
the query. And the semicolon at the end is optional.


didn't know that. Thanks,


Actually, if the fieldname is distinct across all the tables and
queries in the from section of your query, you dont need to
propagate the source name.

Beware however that aliasing names isn't protection against the
distinct(ive)ne ss of a name. I once had a query return an error
message because a name five queries under the called one violated
the rule. Took quite a while to locate that problem.

Bob Q
Nov 12 '05 #6
Chuck Grimsby <c.*******@worl dnet.att.net.in valid> wrote in
news:iq******** *************** *********@4ax.c om:
On Sun, 28 Sep 2003 20:34:00 GMT, Bob Quintal
<bq******@gener ation.net> wrote:
Actually, if the fieldname is distinct across all the tables
and queries in the from section of your query, you dont need
to propagate the source name.
Beware however that aliasing names isn't protection against
the distinct(ive)ne ss of a name. I once had a query return an
error message because a name five queries under the called one
violated the rule. Took quite a while to locate that problem.


I go back and forth on field names in the various tables and
queries I create for that reason.

On the one hand, I think that for clarities sake, two related
fields in two different tables should have the same name, but
then I run into the problem you mentioned on some of the
queries.

Aliasing in the table name helps some (more so then
propagating for me), but it can also confuse. So I go back on
forth on this issue.


A programmer I know assigns a prefix to tables and to fields
within. Table T3014_Item_Defi nitions contained Fields
C3014PK_ItemNum ber, C3014_Descripti on, N3014_ClassKey, N3014_UM.

Table T3022_Item_Grou ps contained N3022PK_Item_Gr oup,
C3022_Descripti on, etc.

Derived fields in queries would get QN0761_Extended Qty

Open a querydef based on querydefs and you could still tell exactly
where everything came from.

I wish I had the discipline to follow his convention.

Bob Q


Nov 12 '05 #7
Bob Quintal <bq******@gener ation.net> wrote:
A programmer I know assigns a prefix to tables and to fields
within. Table T3014_Item_Defi nitions contained Fields
C3014PK_ItemNu mber, C3014_Descripti on, N3014_ClassKey, N3014_UM.

Table T3022_Item_Grou ps contained N3022PK_Item_Gr oup,
C3022_Descript ion, etc.

Derived fields in queries would get QN0761_Extended Qty

Open a querydef based on querydefs and you could still tell exactly
where everything came from.


Interesting idea.

I use table initials as field prefixs. So a field name for ItemDefinitions would be
idID, idDescription, idClassKey. Or ItemGroups would be igID, igDescription,
igInactiveQ and so forth.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Nov 12 '05 #8
"Douglas J. Steele" <dj******@canad a.com> wrote in message news:<5E******* ************@ne ws04.bloor.is.n et.cable.rogers .com>...
I suspect that the function isn't getting a valid value for IDRef, so that
strSQL is only getting Select TotalAdditional FROM qryAddCost WHERE IDRef =,
with nothing else after the equal sign.

Have you got a text box IDRef on the subform that's bound to the query field
IDRef? If so, try renaming the text box to something different than the
field name (say to txtIDRef)

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
"Dalan" <ot***@safe-mail.net> wrote in message
news:50******** *************** ***@posting.goo gle.com...
Please help - just take a quick look at the function code below. It
probably just needs some minor ["] tweaking.

The function module is based on an intermediate query to provide a
group record total from a subform that is posted to a field on the
main form. "Everything seems to work fine" except that I consistently
receive an error everytime I attempt to create a new record on the
main form. However, there are no errors received when accessing
existing records.

It is a Run-Time Error 3075 - Synax error (missing operator) in query
expression 'IDRef=' . And when opening the module, the following is
highlighted: Set rst = CurrentDb.OpenR ecordset(strSQL ). Here is the
code structure of the module:

Function GetTotalAdditio nal(IDRef) As Currency

Dim rst As Recordset, strSQL As String

strSQL = "Select TotalAdditional FROM qryAddCost WHERE IDRef = " &
IDRef

Set rst = CurrentDb.OpenR ecordset(strSQL )

If rst.RecordCount = 0 Then
GetTotalAdditio nal = 0

Else
GetTotalAdditio nal = rst![TotalAdditional]

End If

rst.Close
Set rst = Nothing

Exit Function

End Function
The text box Control Source (AddCost) on the main form uses:
=[Forms]![frmMain]![sfrmAdditionalC osts]![TotalAdditional Cost]

On the subform (continuous forms) the field name is
(TotalAdditonal Cost) and the Control Source is set to:
=GetTotalAdditi onal([IDRef])

The query (qryAddCosts) contains the IDRef as Group By and Total
Additional which is the sum of 3 groups of cost.

Based on the table (tblAdditionalC osts).

I have tried many different things, especially restructuring the code,
but to no avail. Any assistance will be greatly appreciated. Thanks.


Thanks Doug and all for your input. I finally resolved the problem by
including in the code: If Not IsNull(IDRef) Then

I guess that I should listen to Allen a bit more regarding those pesky
"nulls" - lol.
Nov 12 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

29
2477
by: shank | last post by:
1) I'm getting this error: Syntax error (missing operator) in query expression on the below statement. Can I get some advice. 2) I searched ASPFAQ and came up blank. Where can find the "rules" for when and how to use single quotes and double quotes in ASP? thanks! ---------------------- SQL = SQL & "WHERE '" & REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE("GenKTitles.
3
3107
by: KevLow | last post by:
Hi, Hope some kind soul can help me out here.. I'm trying to programmatically modify the column headings of a crosstab query such that it can be dynamic based on user specified period (Month Year to Month Year) So far i have tried to use the following code: //
24
22633
by: deko | last post by:
I'm trying to log error messages and sometimes (no telling when or where) the message contains a string with double quotes. Is there a way get the query to insert the string with the double quotes? Do I need to use code to scrub each string and remove or escape the double quotes before using it in a query? The error I get is this: Error Number 3075: Syntax error (missing operator) in query expression '"credit card billed by...
1
2342
by: amitbadgi | last post by:
I am geting the following error while conv an asp to asp.net Exception Details: System.Runtime.InteropServices.COMException: Syntax error in query expression 'id =System.__ComObject'. Source Error: Line 196: for i = 0 to ubound(emaillist) Line 197: selectsqlstatement = "select * from tblusers where id =" & emaillist(i)
4
1884
by: T. Wintershoven | last post by:
Hi Can someone please tell me whats wrong with the last line of the query below. The first three lines work fine but when i add the fourth line i get an error message (see text at ERROR MESSAGE) sql_HTTermijnRecords = "select * from Orders where FaktuurGeprint = 'J'" & _ "AND dathergestuurd Is Not Null " & _ "AND PerBankKas Is Null " & _
7
6882
by: John Øllgård Jensen | last post by:
Hi Using MS Asccess 2000: In a query I'm trying to create a new field with following expression: FilmDate: Left(,4) The field "FilmNo" is another text field in the query. This is expression should return the 4 leftmost characters of the FilmNo
7
2881
by: bryant | last post by:
Hi all. I am new to ASP and working in Expression Web. The following query displays the information I need in the gridview for a single record. SELECT "OE_HDR"."ORD_NO", "OE_HDR"."CUST_NAM", "OE_HDR"."SLS_MAN_NO", "OE_HDR"."SLS_MAN_INITIALS", "OE_HDR"."ORD_DAT", "OE_HDR"."SHIP_DAT" FROM "OE_HDR" WHERE ("OE_HDR"."ORD_NO"='174310') I also have DropDownList1 working properly. For the WHERE portion of
3
2913
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 IT guy is no where to be found. Everything is working on the new server except for one .asp page in the website that ties to the Access database. When I try and input data on the page and save it I receive the follwoing error: Microsoft OLE DB...
4
11688
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 & 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)
5
8830
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 debugging myself). My problem is in the DLookup command. UserName = Me.cboUserName.Value Debug.Print "User Name is "; UserName strPassword = DLookup("Password", "Employees", "EmpName ='" & UserName) Debug.Print "Password is ";...
0
8618
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9178
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9035
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8916
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8885
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7752
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6534
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4376
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4631
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.