Unanswered: where can i use the opendatabase method(DAO) just once in access 2002?
Help!!!!!!!!! I need to find a way to use the opendatabase method once where the database object i declare is accessible to every object (command buttons etc) I am getting the 3734 error message which is apparently caused by opening and closing the database too much:
dim db_whatever as database
set db_whatever = Opendatabase("F:\blah.mdb")
I have to do this all the time when i use DAO is there not a way I can do this as a public variable available everywhere so I don't have to keep doing this nonsense?????
If you are trying to open the same database that the code resides in, in other words, if you are trying to open the same database that Access currently has open, you should NOT use OpenDatabase.
You should use Application.CurrentDb, which is an already opened DAO Database object to the current databas access has open.
If the database file is NOT the one that access currently has opened, then create a module and declare a global variable, I.E.:
Option Compare Database
Global myConnection as Database
'Any other code to follow...
When this is done, the myConnection variable is available ANYWHERE within your VB code. I don't think global variables can be declared within the vb module of a form or report, only plain & independent vb modules.