473,668 Members | 2,375 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

query problem - recordset not opening / runtime error 3709

JB

Thanks to both of you for responding.

To Pieter: The second asterisk actually isn't there. The original code
reads
just as you suggested it should.
To Phil: I tried changing the 'And' to 'and' --no luck. I also did the
following.

verified that the types of var in the sql statement were the same.
verified that the variables held values at the time the statement is
generated.
verified that the connection was open.
debugger reports :
CurConn.State = 1
Rst.State = 0

With those conditions, the error message is vb runtime error 3709-- "The
connecton cannot be used to perform this operation. It is either closed or
invalid in this context." Maybe I made a mistake in defining CurConn? This
is the code I used before the If statement, if that makes a difference...

Set CurConn = New ADODB.Connectio n

With CurConn
.Provider = "Microsoft.Jet. OLEDB.4.0"
.ConnectionStri ng = CurrentProject. Connection
.Open
End With

Set rst = New ADODB.Recordset
rst.CursorType = adOpenDynamic
rst.LockType = adLockOptimisti c
-Yaw
"Pieter Linden" <pi********@hot mail.com> wrote in message
news:bf******** *************** ***@posting.goo gle.com...
"JB" <im******@nospa m.com> wrote in message news:<10******* ******@corp.sup ernews.com>...
Hello,
I am trying to write a query that selects a row from another table
with a field that matches the Me!RecordingID that's on the form. For some reason my query is not working and the recordset I am trying to build will not open. Can someone help me with this? Thanks for your help!

rst.Open _
"SELECT FROM * ItemsTable *" _
& "WHERE ItemsTable.[ItemID] = Me![RecordingID]" _
& " And Me![ItemID] = ItemsTable.[EntryID], CurConn, , , adCmdText" -Yaw


This query looks a bit dodgy. It should be something like

SELECT * FROM ItemsTable WHERE...

What the extra asterisk is doing there, I don't know, but that will
definitely cause problems.


Nov 13 '05 #1
2 12998
"JB" <im******@nospa m.com> wrote in message news:<10******* ******@corp.sup ernews.com>...
Thanks to both of you for responding.

To Pieter: The second asterisk actually isn't there. The original code
reads
just as you suggested it should.
To Phil: I tried changing the 'And' to 'and' --no luck. I also did the
following.

verified that the types of var in the sql statement were the same.
verified that the variables held values at the time the statement is
generated.
verified that the connection was open.
debugger reports :
CurConn.State = 1
Rst.State = 0

With those conditions, the error message is vb runtime error 3709-- "The
connecton cannot be used to perform this operation. It is either closed or
invalid in this context." Maybe I made a mistake in defining CurConn? This
is the code I used before the If statement, if that makes a difference...

Set CurConn = New ADODB.Connectio n

With CurConn
.Provider = "Microsoft.Jet. OLEDB.4.0"
.ConnectionStri ng = CurrentProject. Connection
.Open
End With

Set rst = New ADODB.Recordset
rst.CursorType = adOpenDynamic
rst.LockType = adLockOptimisti c
-Yaw


Shouldn't it be...

set currConn=Curren tproject.Connec tion

I don't think you even need most of that other stuff...
Nov 13 '05 #2
"JB" <im******@nospa m.com> wrote in message news:<10******* ******@corp.sup ernews.com>...
Thanks to both of you for responding.

To Pieter: The second asterisk actually isn't there. The original code
reads
just as you suggested it should.
To Phil: I tried changing the 'And' to 'and' --no luck. I also did the
following.

verified that the types of var in the sql statement were the same.
verified that the variables held values at the time the statement is
generated.
verified that the connection was open.
debugger reports :
CurConn.State = 1
Rst.State = 0

With those conditions, the error message is vb runtime error 3709-- "The
connecton cannot be used to perform this operation. It is either closed or
invalid in this context." Maybe I made a mistake in defining CurConn? This
is the code I used before the If statement, if that makes a difference...

Set CurConn = New ADODB.Connectio n

With CurConn
.Provider = "Microsoft.Jet. OLEDB.4.0"
.ConnectionStri ng = CurrentProject. Connection
.Open
End With

Set rst = New ADODB.Recordset
rst.CursorType = adOpenDynamic
rst.LockType = adLockOptimisti c
-Yaw


Shouldn't it be...

set currConn=Curren tproject.Connec tion

I don't think you even need most of that other stuff...
Nov 13 '05 #3

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

Similar topics

1
2192
by: Dalan | last post by:
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...
6
11493
by: Nicolae Fieraru | last post by:
Hi All, I have a query, Select Count(BoolField) from tblMyTable, Where BoolField = true. If I run the query by itself, it returns the number of true records I want to use the result of that query in my VBA code, like this: If (result of the query > 0) then do something
3
1821
by: JB | last post by:
Hello, I am trying to write a query that selects a row from another table with a field that matches the Me!RecordingID that's on the form. For some reason my query is not working and the recordset I am trying to build will not open. Can someone help me with this? Thanks for your help! Else 'Update ItemsTable record with new info Debug.Print ("attempting to open recordset") If Me.ItemID <> Null Then
3
12591
by: ILCSP | last post by:
Hello, I'm fairly new to the concept of running action pass through queries (insert, update, etc.) from Access 2000. I have a SQL Server 2000 database and I'm using a Access 2K database as my front end. I'm using a blank pass through query which gets the Transact-SQL part inserted from a button in my form. After inserting the Transact-SQL code into the pass through query, I 'open the recordset' to make the query run. However,...
2
2376
by: roz | last post by:
Hello, I'm fairly new to VB programming and I've been going round the bend with this problem, so any nudges or shoves in the right direction would be greatly appreciated. I have a template form in Word. The information that I need to populate this form is from 2 tables in an Access 2002 database (patient details and GP details). Once the user has entered the patient and GP etc details, they need to produce a case summary (including...
0
4205
MMcCarthy
by: MMcCarthy | last post by:
This is a module that exports information from a Query or a Table to comma separated values in a text format, or using other symbol! It is very helpful for sharing information between the applications! The function that does this work is: create_file_from_SQL_SEP(SQL, File_name, sep) As Integer Parameters: SQL: You can pass a SQL expression, name of a table, or name of a Query that you want to export in csv File_name: You specify the...
9
3048
by: Kelii | last post by:
I've been trying to get this piece to work for a few hours, but have given up. I hope someone out there can help, I think the issue is relatively straightforward, but being a novice, I'm stumped. Below you will find the code I've written and the error that results. I'm hoping that someone can give me some direction as to what syntax or parameter is missing from the code that is expected by VBA. Overview: I'm trying to copy calculated...
6
5312
by: Nano | last post by:
I have created ASP file from MS Access. It has the following Code. But it gives an error at: rs.Open sql, conn, 3, 3 The Error is: Error Type: Microsoft OLE DB Provider for ODBC Drivers (0x80040E10) Too few parameters. Expected
1
1773
by: joefrost | last post by:
I have the following SQL query that keeps giving me a runtime error 800a0401when running through an asp page. The query is below: SELECT (Sum(Abs(DSum("Cath_type","tbl1a_IC")))/10*100) AS CT_Total, (Sum(Abs(DSum("Insertion_site","tbl1a_IC")))/10*100) AS IS_Total, (Sum(Abs(DSum("Skin_prep","tbl1a_IC")))/10*100) AS SP_Total, (Sum(Abs(DSum("PP_eqip","tbl1a_IC")))/10*100) AS PPE_Total, Sum(Abs(DSum("Hand_hy","tbl1a_IC")))/10*100 AS HH_Total,...
0
8459
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
8791
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
8575
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
7398
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...
0
5677
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
4202
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...
1
2784
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2018
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1783
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.