| | |
|
|
|
CurrentDb will not work |
| message from George M on 20 May 2004 |
I am building an application in access2000 as an adp
connected to SQL server 7. In trying to open a record set
in a module I can not get it to work like I have done many
times before in an mdb file, should I be doing something
different?
Code is;
Dim dbs As Database
Dim rst As DAO.Recordset
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tblStaff")
It compiles fine but at run time the "Set rst" line
produces an error "Object Variable or with block variable
not set", hover the mouse over the "Set dbs" statement
says it is still set to Nothing.
Same error with or without a DAO in front of Recordset.
Reference is set to the DAO 3.6 library.
Any guidance would be very much appreciated.
Thanks
George.
|
| Brendan Reynolds replied to George M on 20 May 2004 |
CurrentDb returns a reference to the current Jet database. In an ADP, there
is no current Jet database, and so CurrentDb returns Nothing.
|
| Van T. Dinh replied to George M on 20 May 2004 |
There is no CurrentDB in an ADP.
In fact, if you use ADP, you really should be using ADO
coding rather than DAO.
Check Access VB Help on ADO Recordset.
HTH
Van T. Dinh
MVP (Access)
many
|
| Nikos Yannacopoulos replied to George M on 20 May 2004 |
George,
Dim dbs As DAO.Database
Also, you may need to add parentheses at the end of its Set statement:
Set dbs = CurrentDb()
I believe this will solve your problem.
HTH,
Nikos
"George M" <anonymous@discussions.microsoft.com> wrote in message
news:f84001c43e38$8596cdc0$a101280a@phx.gbl...
|
| anonymous replied to Nikos Yannacopoulos on 20 May 2004 |
Many Thanks, doing the full ADODB did the trick.
Set statement:
set
many
variable
|
|
Archived message: CurrentDb will not work (Microsoft Access)