474,046 Members | 2,499 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Persistent recordset error 91


I get the error msg "Object variable or With block variable not set" when
closing the "persistent " recordset I opened when the application opened.

I have the rs variable declared in the declarations section of a module:

Public rsAlwaysOpen As DAO.Recordset
Then, when the switchboard form loads I set the variable:

Dim dbs As DAO.Database

Set dbs = CurrentDb
Set rsAlwaysOpen = dbs.OpenRecords et("tblGlobals" )

Presumably, the rs will now stay open until I close it in the Unload or Close
event of the switchboard form, but, instead, I get the above error and the rs
appears to be closed (I can't get any values in the Immediate window).

It's only a problem if I open the db with the shift key. Users don't get any
such msgs.

Bill
--
Message posted via AccessMonster.c om
http://www.accessmonster.com/Uwe/For...ccess/200507/1
Nov 13 '05 #1
7 4446
There is a KB article on this. If the dbs goes out of scope, then you may
also lose the subsequent object variables as well. The example you give
isn't exactly the same as the article, but I suspect the problem is the same
one.

http://support.microsoft.com/default...b;en-us;200592

--
Wayne Morgan
MS Access MVP
"Bill R via AccessMonster.c om" <fo***@AccessMo nster.com> wrote in message
news:51******** ***@AccessMonst er.com...

I get the error msg "Object variable or With block variable not set" when
closing the "persistent " recordset I opened when the application opened.

I have the rs variable declared in the declarations section of a module:

Public rsAlwaysOpen As DAO.Recordset
Then, when the switchboard form loads I set the variable:

Dim dbs As DAO.Database

Set dbs = CurrentDb
Set rsAlwaysOpen = dbs.OpenRecords et("tblGlobals" )

Presumably, the rs will now stay open until I close it in the Unload or
Close
event of the switchboard form, but, instead, I get the above error and the
rs
appears to be closed (I can't get any values in the Immediate window).

It's only a problem if I open the db with the shift key. Users don't get
any
such msgs.

Bill
--
Message posted via AccessMonster.c om
http://www.accessmonster.com/Uwe/For...ccess/200507/1

Nov 13 '05 #2

Wayne,

Thanks for your suggestion, but if I understand the article correctly, it
would appear that my code already implements their suggested solution.
I set currentdb to a variable, dbs, and then assign my rs to a dbs.
openrecordset table.

Bill

Wayne Morgan wrote:
There is a KB article on this. If the dbs goes out of scope, then you may
also lose the subsequent object variables as well. The example you give
isn't exactly the same as the article, but I suspect the problem is the same
one.

http://support.microsoft.com/default...b;en-us;200592
I get the error msg "Object variable or With block variable not set" when
closing the "persistent " recordset I opened when the application opened.

[quoted text clipped - 21 lines]

Bill

--
Message posted via http://www.accessmonster.com
Nov 13 '05 #3
I suspect that Wayne is correct in that the problem is that the
database variable you're using (dbs) goes out of scope but I don't
think CurrentDB has anything to do with it. See VBA help on the
Recordset object:

"Note If you use variables to represent a Recordset object and the
Database object that contains the Recordset, make sure the variables
have the same scope, or lifetime. For example, if you declare a public
variable that represents a Recordset object, make sure the variable
that represents the Database containing the Recordset is also public,
or is declared in a Sub or Function procedure using the Static
keyword."

If I were you I'd declare a public database variable and keep my
recordsets private or static.

HTH,
Bruce

Nov 13 '05 #4
I suspect the problem is that your "rst" variable is global but your "dbs"
variable is only valid in the procedure where it runs. When that procedure
is done, "dbs" goes out of scope and you lose the value of "rst" at the same
time.

--
Wayne Morgan
MS Access MVP
"Bill R via AccessMonster.c om" <fo***@AccessMo nster.com> wrote in message
news:51******** ***@AccessMonst er.com...

Wayne,

Thanks for your suggestion, but if I understand the article correctly, it
would appear that my code already implements their suggested solution.
I set currentdb to a variable, dbs, and then assign my rs to a dbs.
openrecordset table.

Nov 13 '05 #5

AHA! Comes the dawn..

Well. I tried makeing both the rs and dbs public, but I'm still getting the
same msg. But, I'm sure I'm on the right track now. I'll let you know how I
make out.

Bill

Bill R wrote:
Wayne,

Thanks for your suggestion, but if I understand the article correctly, it
would appear that my code already implements their suggested solution.
I set currentdb to a variable, dbs, and then assign my rs to a dbs.
openrecordse t table.

Bill
There is a KB article on this. If the dbs goes out of scope, then you may
also lose the subsequent object variables as well. The example you give

[quoted text clipped - 8 lines]

Bill

--
Message posted via AccessMonster.c om
http://www.accessmonster.com/Uwe/For...ccess/200507/1
Nov 13 '05 #6

Got it!

I had my code in the unload or close event of the form. Unfortunately, those
events take place after a docmd.quit command in a cmd button on the same form.
So by the time my code ran, the db was already closed, although intuition
would argue against that, given that the event code is still running in the
db that is closed.

Thanks for pointing me in the right direction.

Bill
--
Message posted via AccessMonster.c om
http://www.accessmonster.com/Uwe/For...ccess/200507/1
Nov 13 '05 #7
Actually, DoCmd.Quit shuts down Access immediately. Once this command
has executed, no other lines in the event procedure will be processed,
nor will control be passed back to any calling routine. Everything
simply stops, right then and there.

Bruce

Nov 13 '05 #8

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

Similar topics

16
3337
by: Paul Rubin | last post by:
I've had this recurring half-baked desire for long enough that I thought I'd post about it, even though I don't have any concrete proposals and the whole idea is fraught with hazards. Basically I wish there was a way to have persistent in-memory objects in a Python app, maybe a multi-process one. So you could have a persistent dictionary d, and if you say d = Frob(foo=9, bar=23) that creates a Frob instance and stores it in d. Then if...
8
2319
by: dmiller23462 | last post by:
My brain is nuked....Can anybody tell me right off the bat what is wrong with this code? Along with any glaring errors, please let me know the syntax to display a message (Response.Write would be fine I think) that will say "I'm sorry but the data you requested cannot be found" or something along those lines.... This code is on an archive page I have on my company's intranet....The end result is to show 3 records at a time pulled from an...
6
1745
by: Alan Silver | last post by:
Hello, I have an ASP that takes a connection string and SQL statement in the querystring and is supposed to return the XML representation of the recordset to the Response stream (don't worry, this is a local page, not one on the Internet). I had it working fine with row-returning SQL, such as SELECT, but was trying to get it to work with non-row-returnign ones as well (such as UPDATE and DELETE). Not only can't I get this bit to work, I...
2
340
by: Eric Ellsworth | last post by:
Hi, I'm working on an Access database which eventually be connected to an ODBC data source (probably postgres), but for now has an .mdb backend. The idea is to use the password to authenticate with postgres when we go to it. I'm using the ebCrypt library to md5 hash passwords and store them hashed in a password table. For the moment I would like to use this system to authenticate without dealing with Access security. I have written...
7
2164
by: Weaver | last post by:
I need to create an object (a recordset) that will not go out of scope outside the sub that creates it. I've tried placing the Dim statement in the General area and in another mod as Global; neither works. (I'm creating the recordset with dynamic SQL.) Any ideas on this?
3
6920
by: Nathan Bloomfield | last post by:
Hi there, I am having difficulty with a piece of code which would work wonders for my application if only the error trapping worked properly. Basically, it works as follows: - adds records from rsSource into rsDest - if it finds a key violation then it deletes the current record from rsDest and adds the new record from rsSource. This works perfectly - but only for the first found duplicate record, it brings up the error
3
4309
by: sanchita | last post by:
Hello everyone, I didn't get any response in "Security" forum hence posting here again. I am having problem with persistent cookies. Even after setting "CreatePersistentCookie" to true in "FormsAuthentication.SetAuthCookie" I'm being logged out after the specifed timeout provided in "forms" element of web.config. I read somewhere that lifetime of persistent cookies depend on the timeout
2
5540
by: wallconor | last post by:
Hi, I am having a problem using Dreamweaver CS3 standard recordset paging behavior. It doesn’t seem to work when I pass parameter values from a FORM on my search page, to the recordset on my results page. - Recordset Paging works if no parameters are used in the recordset sql code (ie. simple sql code): SELECT * FROM db_name WHERE (db_field1 LIKE ‘%text1%’ OR db_field2 LIKE ‘%text2%’)
1
3321
Zwoker
by: Zwoker | last post by:
Hi All, I'm using MS Access 2003. I have a form that allows users to choose various selections from combo boxes. When they click the "go" button it runs VBA code that initially builds SQL code to go get the master records from an Oracle database, using an ODBC connection. Using the recordset created from this master query, it steps through each master record and retrieves various transaction records, also using SQL built on the fly for the...
0
10548
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
11604
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...
0
11143
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
10313
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
7872
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
6654
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
6837
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4944
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3973
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.