Open database

Bosch

Registered User.
Local time
Today, 03:57
Joined
May 13, 2005
Messages
89
What is the best place to have opendatabase statement ? Currently I have opendatabase in all of my forms. I dont have any modules in my application. I am new to access programming. Is module really necessary in an application?
If I can put the opendatabase statement in one place, it will be easier for me to change the database name and path, if I have to..I dont know how to do it.

Can anyone help..I hope this one should easy for many of you people.

Thanks very much.
 
Why do you find yourself using the OpenDatabase method? What are you trying to do with it?
 
Bosch,
Assuming that you are opening one database from within another, I would suggest to link the tables in Db1 to Db2. That would prevent yourself to constantly switch from one db to the other.
 
This is what I am trying to do:

I have backend in my shared drive and front end in my workstation. Front end database links to tables in backend database in Shared drive.

Dont I have to use opendatabase ?

Thanks
 
This is the code I have in OPEN FORM;
I have the similiar code in all of my forms. Is it correct?

Set dbDOCS = OpenDatabase("\\xyzabce\abcd\myjobs\test_be.mdb")

Doc_sql = "Select * from DOCS"
Set doc_rst = dbDOCS.OpenRecordset(Doc_sql, dbOpenDynaset)


Thanks
 
I'm curious as to why you have this on your forms? For what reason? What is it supposed to be doing? Where did you get this technique from?
 
SJ..

I am not an ACCESS expert..I only started programming access 2 weeks ago..I just found in the help and I thought I will need to open the database before I use it. So, I might be wrong. please tell me how I should do it.

Thanks very much.
 
Each form has a RecordSource property. You would set this to the relevant query you want to bind to the form.
 
Please see my code below:

Set dbDOCS = OpenDatabase("\\xyzabce\abcd\myjobs\test_be.mdb")

Doc_sql = "Select * from DOCS"
Set doc_rst = dbDOCS.OpenRecordset(Doc_sql, dbOpenDynaset)

DOCS_TYPE_strFind = " DocType = '" & DocsType_CB.Value & "'"
DOCS_TYPE_rst.FindFirst DOCS_TYPE_strFind

How do you do this without having to create the recordset? And I am still confused about why I dont have to open the database before using it.

Thanks
 
Can Anyone help me!

I am really stuck..I am not an access programmer..but trying to be one.

In the above code what I am trying to do is, before adding or updating a record, I am checking if the record exists in the table. For that I am using FindFirst method of Recordset object. To create a recordset object I have to create a database object.. thats the reason I have the above opendatabase statement.

I have the database object declared in a module. and opening the database in open form even of the main form.

Now, I am getting 'object not set' error.
Any ideas?
 

Users who are viewing this thread

Back
Top Bottom