|
-
November 20th, 1999, 08:47 PM
#1
Use common dialog to open a database
I'm hoping someone can help me with a newbie problem here...
I want to use a common dialog to allow a user to open a database. How do I get the database name and path from the common dialog and then open the database for use by some simple forms.
Thanks in advance.
-
November 21st, 1999, 07:13 PM
#2
Re: Use common dialog to open a database
The answer to your question is as follows:
--
Dim strFilePath As String
Dim strDatabase As String
CommonDialog1.ShowOpen
strFilePath = CommonDialog1.FileName
strDatabase = CommonDialog1.FileTitle
--
CommonDialog1.FileName will return the full path of the database.
CommonDialog1.FileTitle will return just the name of the database.
Good question.
Allen Noakes
VB Programmer/Analyst
Dames & Moore Group
[email protected]
-
November 29th, 1999, 06:07 PM
#3
Re: Use common dialog to open a database
Allen,
Thanks for the reply.
I understand your suggestion and I will use that. What I am doing is using a standard module to load some forms and control the common dialog to select the database. Some of the forms (MDIchild forms) have the controls on them to access the database. Is there a need (or a smart way) to open the database for processing so that the strDatabase and strFilePath variables can simply be passed to the controls to allow their processing.
Without dumping the whole project so far on here, this is slightly complex. I guess a application or code sample would help me. Any suggestions?
Thanks once again for your help.
Simon
-
November 29th, 1999, 06:20 PM
#4
Re: Use common dialog to open a database
You could have the path/database name in a global variable (declared in a bas module), or a better (OO) method would be to have a single instance of a class which stores the database details. You could then update the class on the fly and notifies the forms accordingly (with events)
Chris Eastwood
CodeGuru - the website for developers
http://codeguru.developer.com/vb
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|