Rabu, 06 Februari 2013

RE: [MS_AccessPros] run-time error '91' object variable or with block variable

 

John-

Is there a Debug button on the error message? If you click that, it should
tell you which statement is failing.

Also, I don't like using CurrentDb to open a Recordset. You have a Database
object declared - why not use it?

Set db = CurrentDb
Set rsAlwaysOpen = db.OpenRecordset("tblKeepOpen")

John Viescas, Author
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications
SQL Queries for Mere Mortals
http://www.viescas.com/
(Paris, France)

-----Original Message-----
From: MS_Access_Professionals@yahoogroups.com
[mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of jfakes.rm
Sent: Wednesday, February 06, 2013 9:10 PM
To: MS_Access_Professionals@yahoogroups.com
Subject: [MS_AccessPros] run-time error '91' object variable or with block
variable

When I open one of my databases normally (not shift enter), when I click on
the exit access command on the menu, I get a "run-time error '91' object
variable or with block variable."

I finally figure out that it has something to do with a form I use to
maintain a permanent connection to the back end.

Following is the code for the form. Note: tblKeepOpen is a linked table in
the backend used to maintain the connection.

Can someone please explain what I've done wrong here?

Option Compare Database
Option Explicit
Dim db As DAO.Database, rst As DAO.Recordset

Public rsAlwaysOpen As Recordset
Private Sub Form_Close()
rsAlwaysOpen.Close
Set rsAlwaysOpen = Nothing

End Sub
Private Sub Form_Open(Cancel As Integer) 'Set rs =
db.OpenRecordset("tblKeepOpen", dbOpenDynaset)
Set rsAlwaysOpen = CurrentDb.OpenRecordset("tblKeepOpen")
End Sub

John F.

------------------------------------

Yahoo! Groups Links

__._,_.___
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (2)
Recent Activity:
.

__,_._,___

Tidak ada komentar:

Posting Komentar