473,667 Members | 2,576 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

query problem - recordset not opening

JB
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
'Opens the recordset, getting the matching row from the itemstable with
the current itemid
rst.Open _
"SELECT FROM * ItemsTable *" _
& "WHERE ItemsTable.[ItemID] = Me![RecordingID]" _
& " And Me![ItemID] = ItemsTable.[EntryID], CurConn, , , adCmdText"
End If
'Recorset Status
If rst.State = 1 Then
Debug.Print ("Open Recordset! " & rst.RecordCount & " Records Selected")
'Determines whether records were found in the query
If rst.RecordCount <> 0 Then
rst![ItemAccessed] = Me![lblAccessed].Caption
rst![ItemModified] = Me![lblModified].Caption
rst.Update
MsgBox ("Record Updated Successfully!!" )
End If
End If
Set rst = Nothing
CurConn.Close
End If

-Yaw
Nov 13 '05 #1
3 1820
JB <im******@nospa m.com> posted in
news:10******** *****@corp.supe rnews.com
& " And Me![ItemID] = ItemsTable.[EntryID], CurConn, , ,

try
& " and " & me![itemid] & " itemstable etc.
--
Phil
Nov 13 '05 #2
"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 #3
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 #4

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

Similar topics

20
10138
by: | last post by:
If I need to check if a certain value does exist in a field, and return either "yes" or "not" which query would be the most effestive?
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
2
5367
by: Anderson | last post by:
I have a table which has employee number. I have attempted to creat a function whic will derive a unique number for each record how ever the code below only returns 10,000 for all records. What I am doing wrong? I am I right in saying that In assuming that I dont to loop since I am returnign this for a every record in query. Your help will be greatly appreciated. Function Generate_Number(emp_no As Variant) As Variant Dim strSQL As...
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,...
3
11553
by: eagleofjade | last post by:
I am trying to help a friend who is learning VB.net in school. I have done VB programming for a number of years using VB 6. He needs to open a query in an Access database that has parameters so he can work with the returned records. In VB 6, I use DAO and do it this way: Dim db As Database Dim rs As Recordset Dim qd As QueryDef
3
2092
by: visionstate | last post by:
Hi All, I have used the following article to help me build a query 'on the fly': http://www.fontstuff.com/access/acctut17.htm It's a very useful article and is exactly what I was looking for to use in my current project. To give you a brief rundown I am basically creating a Training Database which would allow users to choose 1 or more options from a drop down box to select the criteria I need.
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...
8
6480
by: SaltyBoat | last post by:
Needing to import and parse data from a large PDF file into an Access 2002 table: I start by converted the PDF file to a html file. Then I read this html text file, line by line, into a table using a code loop and an INSERT INTO query. About 800,000 records of raw text. Later, I can then loop through and parse these 800,000 strings into usable data using more code. The problem I have is that the conversion of the text file, using a...
6
2555
by: Vince | last post by:
Hello all, I am using Visual Basic to open a saved query and then save information in the query to an array for later use. The problem is that the same query shows different results when opened directly vs. when opened by Visual Basic. It is as if Visual Basic is not letting the query fully evaluate before processing records. The query is a subtotal query that contains several criteria set up as "where" in the group-by box. Most of...
0
8883
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
8788
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
8563
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
8646
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
7390
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
6203
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
5675
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
4200
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
4372
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.