Database Name

G

Guest

I have 2 databases that are very similiar and I swap a specific form between
them frequently, the forms do different things based on the database they are
in.

Is there anyway I can find out the name of the database that the form is
coming from and then use an ifthenelse statement to run code

ie:
if database name = "one" then
domcd.quit
else
docmd.openform "form1"
end if


Thanks in advance
 
G

Guest

Hi, Nigel.
Is there anyway I can find out the name of the database that the form is
coming from and then use an ifthenelse statement to run code

If you are running Access 2000 or later, then the following code would work:

If (CurrentProject.Name = "one") Then
DoCmd.Quit
Else
DoCmd.OpenForm "Form1"
End If


HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)
- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.
 
L

Larry Linson

CurrentDB().Name will give you the fully qualified path and filename of the
current MDB database.

Larry Linson
Microsoft Access MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top