how to return back to another open db using vba

sspreyer

Registered User.
Local time
Today, 04:06
Joined
Nov 18, 2013
Messages
251
hi ,

currently have some code on (database A) to open a form in (database B). cant seem to work out how to return from database B to Database A without having to click the task bar to open the db window is their any way i can have some code on say database b form to return to database A () and restore Database A window and close Database B.

any help much appreciated

Shane
 
If you closed database A when you opened database B, you can do this:

Code:
Call Shell("msaccess.exe " & "path to database A here")
Application.Quit

However if database A is still open that will fail
 
[
However if database A is still open that will fail

Yeah I understand procredure to open the dB but problem like you stated the dB is still open :/ that’s my problem wonder is there way to call say restore window database A from database b

Thanks

Shane
 
Before going further, how would you know which form (and on what record) you would be returning to? Does database B know this some how? Or are you saving it in a local file of some type?
 
@sspreyer

What are you wanting to do on this form in database B. There must be some event to indicate something is finished. I also wonder why database a has to be closed and then re-opened. Why not leave it open?

Also depending what you want to do in database b, you could open a reference to database b from within database a and do whatever.
 
currently have some code on (database A) to open a form in (database B). cant seem to work out how to return from database B to Database A without having to click the task bar to open the db window is their any way i can have some code on say database b form to return to database A () and restore Database A window and close Database B.

Pass the HWnd of the calling form in OpenArgs when opening the other form. Then return to the original form by setting the active window with the HWnd using an API call with SetActiveWindow.
 
Pass the HWnd of the calling form in OpenArgs when opening the other form. Then return to the original form by setting the active window with the HWnd using an API call with SetActiveWindow.

you have completely lost me Lol here is how i open database b

Code:
DoCmd.RunCommand acCmdAppMinimize
Dim objAdb As Object

Dim appAccess As Access.Application
Set appAccess = New Access.Application
appAccess.OpenCurrentDatabase ("C:\Users\sspreyer\Desktop\DATABASE B.accdb")
'Optional, if App needs to be visible
'appAccess.Visible = True
Set objAdb = CreateObject("Access.Application")
appAccess.DoCmd.Close acForm, "Startupformclose", acSaveYes
appAccess.DoCmd.OpenForm "openformnamedatabase b", , , "DbID=" & ID.Value
appAccess.DoCmd.Maximize



End Sub

thanks in advance

shane
 
@sspreyer

What are you wanting to do on this form in database B. There must be some event to indicate something is finished. I also wonder why database a has to be closed and then re-opened. Why not leave it open?

Also depending what you want to do in database b, you could open a reference to database b from within database a and do whatever.

hi cronk

database A holds Job card information and database B is a stock control data base its show which parts have been booked to that job card. The user using database A will not be updating database b its just for information. for database A user. see above my procedure to open DB B. Database A is also always open

thanks

shane
 
Shane,

Why don't you just link in database A to the tables in database B and display in database A. Better still, why not have all the relevant tables in one place.
 
Shane,

Why don't you just link in database A to the tables in database B and display in database A. Better still, why not have all the relevant tables in one place.

Yeah that makes sence Cronk

cheers
shane
 

Users who are viewing this thread

Back
Top Bottom