473,796 Members | 2,599 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need Assistance to Resolve Query Syntax Error

I'm experiencing a Query Syntax Error with an Access 97 Db. Actually,
the query performs as expected when adding any new records or editing
existing ones and even deleting records, EXCEPT when the last record
on any related subform is deleted, then it generates a Runtime Error
3075 - Syntax error (missing operator) in query expression 'IDRef =
'-- of course, because there are no more records left with the same
IDRef number, or none remaining on the subform. And Set rst =
dbs.OpenRecords et(strSQL) is highlighted in the Function module.

The Function module below pulls the IDRef numbers and amounts from a
Totals Query. There is sfrmAddCost subform on a frmMain and when
adding or editing the subform records all is fine. It is when the only
or last record is deleted that the above error appears.

I have tried several approaches to resolve this specific issue, but to
no avail. Would appreciate any assistance and advice. Thanks, Dalan
Function GetTotalAdditio nal(IDRef) As Currency

Dim rst As Recordset, strSQL As String
Dim dbs As Database
Set dbs = CurrentDb
If Not IsNull(IDRef) Then

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

Set rst = dbs.OpenRecords et(strSQL)

If rst.RecordCount = 0 Then
GetTotalAdditio nal = 0
Else
GetTotalAdditio nal = rst![TotalAdditional]

End If
End If

Set rst = Nothing
Set dbs = Nothing

Exit Function

End Function
Nov 12 '05 #1
1 2196
You could either change the code that builds the SQL statement to something
like "WHERE IDRef = '" & NZ(YourControlR eferenceHere, "") & "'", in which
case you'll get an empty recordset (assuming that an empty string is not a
valid value for the field) or, perhaps better, check whether the control
reference returns Null before trying to build the SQL string and open the
recordset ...

If IsNull(YourCont rolReferenceHer e) Then
'do whatever is appropriate
Else
'build your SQL string and open the recordset
End If

--
Brendan Reynolds

"Dalan" <ot***@safe-mail.net> wrote in message
news:50******** *************** ***@posting.goo gle.com...
I'm experiencing a Query Syntax Error with an Access 97 Db. Actually,
the query performs as expected when adding any new records or editing
existing ones and even deleting records, EXCEPT when the last record
on any related subform is deleted, then it generates a Runtime Error
3075 - Syntax error (missing operator) in query expression 'IDRef =
'-- of course, because there are no more records left with the same
IDRef number, or none remaining on the subform. And Set rst =
dbs.OpenRecords et(strSQL) is highlighted in the Function module.

The Function module below pulls the IDRef numbers and amounts from a
Totals Query. There is sfrmAddCost subform on a frmMain and when
adding or editing the subform records all is fine. It is when the only
or last record is deleted that the above error appears.

I have tried several approaches to resolve this specific issue, but to
no avail. Would appreciate any assistance and advice. Thanks, Dalan
Function GetTotalAdditio nal(IDRef) As Currency

Dim rst As Recordset, strSQL As String
Dim dbs As Database
Set dbs = CurrentDb
If Not IsNull(IDRef) Then

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

Set rst = dbs.OpenRecords et(strSQL)

If rst.RecordCount = 0 Then
GetTotalAdditio nal = 0
Else
GetTotalAdditio nal = rst![TotalAdditional]

End If
End If

Set rst = Nothing
Set dbs = Nothing

Exit Function

End Function

Nov 12 '05 #2

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

Similar topics

7
3824
by: Julien - Marseille | last post by:
Hello, I need help for php syntax when i call Mysql database I have wrote that and my sql connection is working I just have a problem with this command line : $query = "SELECT * FROM utilisateurs WHERE pseudo_utilisateur='$login';";
5
32238
by: Subrahmanyam Arya | last post by:
Dear oracle gurus, I am unable to get past the error ORA-12154: TNS: could not resolve service name on my host when using hsodbc to talk to a remote mysql database. i got from the meta link all the needed documenatation to configure inithsodbc.ora,listener.ora,tnsnames.ora and related errors Here is what it says ORA-12154: SQL> select * from all_catalog@demo;
0
1173
by: Kevin Michael Reed | last post by:
------=_NextPart_000_002B_01C34DF8.C34C94F0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Assistance required. I have 3 tables:
22
1643
by: Daniel Antonson | last post by:
Fellow programmers, As one of you pointed out, I've been taking 3 online courses (2 are done) and have run into a time crunch. I started these courses in Oct04, but between work (US Army in DC), caring for my wife (stroke in Dec03 due to lupus complications) & daughter (4), and preparing for transfer/deployment (my stepson,- 23, says he'll care for them during my absence). I've had little time for anything else. I would greatly...
4
6541
by: MLH | last post by:
I apologize in advance to forum readers noticing this somewhat redundant post. I fear that my Subject Heading was ill-chosen in earlier post I made on this topic. Am hoping that a clearer Subject heading will attract the knowledgeable forum contributors I'm seeking. Thank-you... I'm being academically challenged trying to build a pass-through query inside of Access 2.0 to "reach out 'n touch" a remote data file running on a Linux box in...
1
1685
by: Dalan | last post by:
I'm not certain if this is doable in the manner explained below, but surely there have been others who have done something similar. So whatever insight and assistance that can be provided will be much appreciated. I working with a separate Update Query (well several) that consolidate various goods from separate tables for access and selection on a sales/order invoice form. The data which is available is the TagNo,ItemDescrip, Quantity...
8
2617
by: Tcs | last post by:
I've been stumped on this for quite a while. I don't know if it's so simple that I just can't see it, or it's really possible. (Obviously, I HOPE it IS possible.) I'm trying to get my queries to run from VB. My pass-thru query retrieves data from our AS/400 that I use to build a local table (on my PC). My pass-thru and local do in fact work together when I run them interactively. But I want, no make that NEED, to run them from VB. ...
0
2263
by: ward | last post by:
Greetings. Ok, I admit it, I bit off a bit more than I can chew. I need to complete this "Generate Report" page for my employer and I'm a little over my head. I could use some additional assistance. I say additional because I've already had help which is greatly appreciated. I do try to take the time and understand the provided script in hopes on not having to trouble others on those. But here it goes...
6
1913
by: jwgrafflin | last post by:
I keep getting the same error: This code works just fine on another site, and all the other php pages work just fine. But this one is driving me nuts trying to figure out the problem. <?php $hostname=$_POST; $url=$_POST; $established=$_POST;
0
9685
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9531
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
10459
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
10018
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...
1
7553
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
6795
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5446
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
5578
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2928
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.