|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Error 91 after compiling but not during runtimeHi All,
I have created a VB program which opens a DAO database and recordset. When I use the program in runtime there is no problem but when I compile the program and try to run if again I'm getting the error 91 Object variable ....... The problem is this line: Set rs = db.OpenRecordSet(sql, dbOpenDynaSet) I have declared the db and rs: Public db as DAO.Database Public rs as DAO.Recordset Anyone knows where this strange behaviour comes from?
Show quote
"Co" <vonclausow***@gmail.com> wrote in message 'db' isn't initialized.news:fdfb2833-5689-481c-980f-ec403234da82@o6g2000hsd.googlegroups.com... > Hi All, > > I have created a VB program which opens a DAO database and recordset. > When I use the program in runtime there is no problem but when I > compile the program > and try to run if again I'm getting the error 91 Object > variable ....... > > The problem is this line: > Set rs = db.OpenRecordSet(sql, dbOpenDynaSet) > > I have declared the db and rs: > > Public db as DAO.Database > Public rs as DAO.Recordset > > Anyone knows where this strange behaviour comes from? > Add one of the following. Set db = CurrentDb() Set db = dbEngine.OpenDatabase(...)
Show quote
"Co" <vonclausow***@gmail.com> wrote in message What does yournews:fdfb2833-5689-481c-980f-ec403234da82@o6g2000hsd.googlegroups.com... > Hi All, > > I have created a VB program which opens a DAO database and recordset. > When I use the program in runtime there is no problem but when I > compile the program > and try to run if again I'm getting the error 91 Object > variable ....... > > The problem is this line: > Set rs = db.OpenRecordSet(sql, dbOpenDynaSet) > > I have declared the db and rs: > > Public db as DAO.Database > Public rs as DAO.Recordset > > Anyone knows where this strange behaviour comes from? Set db = line look like?
Show quote
On 29 nov, 14:38, "Norm Cook" <normcookNOS***@cableone.net> wrote: Set db = OpenWorkspaces(0).dbEngine.OpenDatabase(...)> "Co" <vonclausow***@gmail.com> wrote in message > > news:fdfb2833-5689-481c-980f-ec403234da82@o6g2000hsd.googlegroups.com... > > > > > Hi All, > > > I have created a VB program which opens a DAO database and recordset. > > When I use the program in runtime there is no problem but when I > > compile the program > > and try to run if again I'm getting the error 91 Object > > variable ....... > > > The problem is this line: > > Set rs = db.OpenRecordSet(sql, dbOpenDynaSet) > > > I have declared the db and rs: > > > Public db as DAO.Database > > Public rs as DAO.Recordset > > > Anyone knows where this strange behaviour comes from? > > What does your > Set db = > line look like?
Show quote
"Co" <vonclausow***@gmail.com> wrote in message What's an "OpenWorkspaces"?news:cd994c3e-db98-4a00-9afe-c2f14bdcc20a@i29g2000prf.googlegroups.com... > On 29 nov, 14:38, "Norm Cook" <normcookNOS***@cableone.net> wrote: > > "Co" <vonclausow***@gmail.com> wrote in message > > > > news:fdfb2833-5689-481c-980f-ec403234da82@o6g2000hsd.googlegroups.com... > > > > > > > > > Hi All, > > > > > I have created a VB program which opens a DAO database and recordset. > > > When I use the program in runtime there is no problem but when I > > > compile the program > > > and try to run if again I'm getting the error 91 Object > > > variable ....... > > > > > The problem is this line: > > > Set rs = db.OpenRecordSet(sql, dbOpenDynaSet) > > > > > I have declared the db and rs: > > > > > Public db as DAO.Database > > > Public rs as DAO.Recordset > > > > > Anyone knows where this strange behaviour comes from? > > > > What does your > > Set db = > > line look like? > > Set db = OpenWorkspaces(0).dbEngine.OpenDatabase(...) It looks like you're making it more convoluted than it has to be. The DBEngine object is the main object. It contains two collections: Workspaces and Errors. Workspaces is the default so you can access it without a explicit reference. If you need a Workspace then fetch it from the DBEngine. Dim ws as DAO.Workspace Dim db as DAO.Database Set ws=DBEngine.Workspaces(0) set db=ws.OpenDatabase(...) Otherwise just use the DBEngine. -ralph |
|||||||||||||||||||||||