Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Browse and Choose a DB and Table From a Macro

Status
Not open for further replies.

LOKIDOG

Technical User
Apr 25, 2001
150
US
I did not know where else to put this question - It's about a Macro - but I could also accomplish this in a Form so...

I put together a Macro to do a fairly simple task. I import a table from a Access Database - TransferDatabase Action

Then I Open a query that makes a table based on the imported table and another table in the database. OpenReport Action

But I would love to be able to open a dialog to choose the name of the Database, then dialog to choose the table to open in the TransferDatabase Action step.

Any ideas?

thread702-1152344 seems somewhat appropriate, but not completely. And I need more info - like how to call the function once created. Much Thanks!
 
Browsing for files comes up quite a bit, for example, here is another thread:
<<< Need HELP with code to Browse a file folder >>>
thread702-942443

To do what you want, you will need a form with textboxes for the answers. These answers can then be used for the transfer. It would not be too difficult in code, but I am not sure about macros. Code can be run from command buttons or events. For example
* create a form with a combobox called cboTables
* a textbox called txtFileName
* and a command button to run the file picking code
* pick a file and add it to a textbox called txtFileName

This code:
Code:
Private Sub txtFileName_AfterUpdate()
Me.cboTables.RowSource = "SELECT [MSysObjects].[Name] " _
& "FROM MSysObjects IN '" & Me.txtFileName _
& "' WHERE [MSysObjects].[Type] In (1,6) " _
& "And Left([MSysObjects].[Name],4)<>'MSys';"
End Sub

Would list the tables in the selected file.
 
I think I'll experiment with this for awhile. Then attempt to run it from a macro - you can call up a form, or code from a Macro, so maybe that will be the way it will work. I may be able to do it all from a form too - with command buttons that run Macros! Thanks. I'll let you know how it goes.
 
How are ya LOKIDOG . . .

Just a thought . . . how about calling the [blue]Import Dialog[/blue] (no TransferDatabase Action required):
Code:
[blue]   docmd.RunCommand acCmdImport[/blue]
Then continuing with the rest of your code?

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top