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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Use One DB Form to Control Several DBs 1

Status
Not open for further replies.

accessjack

Programmer
Dec 2, 2004
28
US
I would like to use one database form to run an update in 4 external access databases.

Master.mdb has 1 form called frmAutomation which has one combo box called cboPeriod. I would like to add a command button to this form adding vba code to the "on click" event. When clicked, the code will open the 1st external database (db1.mdb); then open a specific form (frm1); pass the value from the combo box on frmAutomation to populate the combo box on frm1 called cbo1; and lastly click on the existing command button (btn1) which updates the external database. A tricky part is the update takes a couple minutes, so the the code will have to wait for the vba code execute, then close the db connection, before moving on to the 2nd external db (db2.mdb) and repeating the process until all 4 databases are updated.

There is no need need for the external databases to be displayed while the updates are actually happening, so the vba code provided can do it's work in the background with some type of message when complete.

The reason for this is right now I have to manually open each database, press a button, wait, and do it all over again 4 times. I really like to automate this long-update process.

Any help is appreciated.
Regards,
AccessJack



 
if what you mean by update "external access databases" the tables in the external access databases. then link those to to master database and the are all internam db but if what you mean is form and/or contrls
try this code

MSaccessHelp said:
' Include the following in Declarations section of module.
Dim appAccess As Access.Application

Sub DisplayForm()

Dim strDB as String

' Initialize string to database path.
Const strConPathToSamples = "C:\Program " _
& "Files\Microsoft Office\Office11\Samples\"

strDB = strConPathToSamples & "Northwind.mdb"
' Create new instance of Microsoft Access.
Set appAccess = _
CreateObject("Access.Application")
' Open database in Microsoft Access window.
appAccess.OpenCurrentDatabase strDB
' Open Orders form.
appAccess.DoCmd.OpenForm "Orders"
End Sub



[/qoute]
 
Thanks pwise. Since ultimately the form in the external db was updating a table in the external database, by linking the tables, and importing the form, I was able to update the data in the external databases locally.

Thanks.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top