How to check if the Linking Table Screen (acCmdLinkTables) has been closed

M

Marcel Stoop

Hi everyone

With -DoCmd.SelectObject acTable, , True- I open the Database Screen,
subsequently I open the Screen
-DoCmd.RunCommand acCmdLinkTables- for Linking new Tables.

After the user has been finished with linking new Tables I want to close the
Database Screen again.
For this I use:
DoCmd.SelectObject acTable, , True
RunCommand acCmdWindowHide

Problem:
How can I check that the user has finished linking new tables, respectively
has closed the Linking Table Screen.
Because, upon closing the "Linking Table Screen" I want to perform:
DoCmd.SelectObject acTable, , True
RunCommand acCmdWindowHide

(I guess the problem will also be that there are two Screens: The "Linking"
screen and the "Choose Datasource" screen.)

Cheers
Marcel
 
J

Joan Wild

You don't need to display the database window in order to relink. Just use
DoCmd.RunCommand acCmdLinkTables
 
M

Marcel Stoop

Are you Really sure??

I Tested a lot in this direction, and came to the conclusion that you have
to open the Database Screen.
Without opening the Database Screen you can not open the Screen for linking
tables.

Could you please verify this, because if you are right, then I sure want to
know what kind of settings you used, or what exactly you did to achieve
this. Perhaps I overlooked something.

Cheers
Marcel

PS: I know I can also code this whole procedure with TableDef. Because of
some environment comstraints, this is unfortunately not an option.
 
J

Joan Wild

I just tested and it works for me. On a form, a command button with
DoCmd.RunCommand acCmdLinkTables

Startup is set to not show the db window.

Click the button, the linked table manager opens, I refresh the links, and
close the dialog.

I'm back to the form - the db window never shows up.

If you prefer, you can use the code at
http://www.mvps.org/access/tables/tbl0009.htm
to relink tables.
 
M

Marcel Stoop

Hi

You are right, it also worked for me this time (Button on a Form).
Perhaps you can explain me what I did wrong in my previous settings.

What did I do:
On my Menubar I have created a Button. For the "On Action:" Attribute I have
set: = LinkTableDialog()

This "= LinkTableDialog()" refers to the Function:

Function LinkTableDialog()
DoCmd.RunCommand acCmdLinkTables
End Function

I have put this Function in a separate Module

This only works when the Database Screen is already opened, meaning that it
only works when the Function looks like:
Function LinkTableDialog()
DoCmd.SelectObject acTable, , True
DoCmd.RunCommand acCmdLinkTables
End Function

I do not understand that it works when I put DoCmd.RunCommand
acCmdLinkTables behind a Button on a Form, but not when I do it in the above
mentioned way.

I still want to call DoCmd.RunCommand acCmdLinkTables from a Menubar Button.
What do I have to do to make this work.

Thanks again for the help.

Cheers
Marcel
 
J

Joan Wild

Why don't you just copy the Tools, Database Utilities, Linked Table Manager
item from the built-in menubar to your custom menubar? Just hold down the
ctrl key while you drag it to your custom menu.

I'm not sure why your method didn't work. The module isn't named the same as
your function is it (it shouldn't be)?
 
M

Marcel Stoop

Hi

I copied the "Link Table" Item in my Menubar.
Unfortunately this is only shown in Read-Only mode.
As Soon as I have opened the Database Screen, this button is not read only
anymore.

Seems that the weird behaviour continues.

Cheers
Marcel
 

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