call Form by button

  • Thread starter Thread starter Anna
  • Start date Start date
A

Anna

I link my tables by link option is it possible that on a button in a
form i can call a form which resides in another database.

Thank You.
 
Hi Anna

There are a number of methods that people but the standard is to use a Call
Shell function. You need also to (once the other D Base is open) open the
other form, so many people (me included) will do a bit of a cheat here and
use a macro (in the other D Base).

Have a try with something like this

Private Sub Button Name_Click()
On Error GoTo ButtonName_Click_Err

Call Shell("""C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE""
""S:\MyDocuments\MyDataBase.mdb""/XOpenNewForm", 1)

ButtonName_Click_Exit:
Exit Sub

ButtonName _Click_Err:
MsgBox Error$
Resume ButtonName _Click_Exit

End Sub

Ensure you leave all the """"""""" and ((((())))) and other stuff (just
change the names) where I have put them. For more information on these doa
search in this forum as some new users find them a problem.

To explain

Call Shell("""Location of new D Base"" ""Full path of new D
B""/XMacroName", 1)

To find the location of the D Base (could be C drive or on a server it will
be somewhere else) use the Start – Run – Browse and then look for the
programme (don’t click the run option, after you have found it simply
Cut-N-paste it into your code). You can use the same method to find the path
of your MDB.
The macro will need to be stored in the other DataBase and called from the
code in your current (the one with this code) the X simply tell access it’s
a macro ie. XMacroName (which why you should never start the name of a
macro with an X.
 
Thanks for your reply. This is the code which simply use in my button,
only change the path where my other database resides or is there any
thing else i mean macros which i have to create in my current database
as i dont have any experience in macros.

Thank You.
 
Hi Anna
Thanks for your reply. This is the code which simply use in my button,
There is no code attached to your message ??

The Call Shell will open the other database but when "you get there" you
want the other database to open at a specific form. So what you need to do
is run a macro as soon I you arrive at the other database to open the form.

Sorry if I have not explained it very well English is not my 1st language.

You need to open the other database - the one one you want to "call".
The create a new Macro

* Click Macro (on the left of the screen)
* Click New (at the top of the screen)
* In the "Action" column scroll down to "OpenForm"
* In the options box (lower section of the macro screen) scroll down to the
form you want to open.
* Just to start with (you can change it later) I would leave the View at
"Form" and leave "Fitler" Data" and "Where" all blank.
* For the Mode try "Normal" for now.
* Save the macro as TransOpenForm

I normally put trans at the start of names if I am calling it from a
"transfer" but this is up to you.

If you do use TransOpenForm

Then the code would be
""C:\MyDocuments\MyDataBase.mdb""/XTransOpenForm", 1)
"If" your d base in on your C drive - you will need to alter the text

MyDocuments \ MyDataBase
to show the location of the file and the name of the MDB (d Base)




--
Wayne
Manchester, England.
Not an expert.
Enjoy whatever it is you do.
 
Back
Top