Solved

MS Access Open another database from current and close Current

Posted on 2016-09-30
5
25 Views
Last Modified: 2016-09-30
I have two databased files.  CurrentDb and HistoryDB  in MS Access 2003.
From a form in HistoryDB on  command button click event I need next:
 I want to open two bound forms in CurrentDB with particular record in
then I want to close HistoryDB and have CurrentDB form frmMainEdit stay  opened and frmMainOutstand should be hidden.
I started with some code as bellow but can not figure out how to close HistoryDB at the end of procedure and have CurrentDB open.
   
********************************************

Private Sub CmdOpen_Form_In_CurrentDatabase_Click()


Dim strDB As String
strDB = "D:\Databases\CurrentdB.mdb"
   
Dim appAccess As Access.Application
Set appAccess = New Access.Application

Dim strFilter1 as string
strFilter1 = "Some text xxxxxx"


appAccess.OpenCurrentDatabase strDB
appAccess.Visible = True

appAccess.UserControl = True





stDocName = "frmMainOutStand"
appAccess.DoCmd.OpenForm stDocName

Forms!frmMainOutstand!sfrmMainOutStandCurr.Form.Filter = strFilter1
Forms!frmMainOutstand!sfrmMainOutStandCurr.Form.FilterOn = True


Forms!frmMainOutstand!sfrmMainOutStandHis.Form.Filter = strFilter1
Forms!frmMainOutstand!sfrmMainOutStandHis.Form.FilterOn = True






stDocName = "frmMainEdit"
appAccess.DoCmd.OpenForm stDocName

Forms!frmMainEdit.Form.Filter = strFilter1
Forms!frmMainEdit.Form.FilterOn = True

End Sub
0
Comment
Question by:Taras
  • 3
  • 2
5 Comments
 
LVL 7

Accepted Solution

by:
COACHMAN99 earned 500 total points
Comment Utility
Did you try docmd.quit after all your other code
0
 

Author Comment

by:Taras
Comment Utility
Path It works but:

I got this part working
stDocName = "frmMainEdit"
appAccess.DoCmd.OpenForm stDocName

Forms!frmMainEdit.Form.Filter = strFilter1
Forms!frmMainEdit.Form.FilterOn = True
And I can see at bottom of form is saying: Filtered


It works but I can not get this part to work:

stDocName = "frmMainOutStand"
appAccess.DoCmd.OpenForm stDocName

Forms!frmMainOutstand!sfrmMainOutStandCurr.Form.Filter = strFilter1
Forms!frmMainOutstand!sfrmMainOutStandCurr.Form.FilterOn = True


Forms!frmMainOutstand!sfrmMainOutStandHis.Form.Filter = strFilter1
Forms!frmMainOutstand!sfrmMainOutStandHis.Form.FilterOn = True

And I can see at bottom of form is saying Unfiltered ???
0
 
LVL 7

Expert Comment

by:COACHMAN99
Comment Utility
DID DOCMD.QUIT WORK?
0
 

Author Comment

by:Taras
Comment Utility
Yes ,  but now filter on one  form is working but not working on those two sub forms.  
Should I post separate question for that?
0
 

Author Closing Comment

by:Taras
Comment Utility
Thank you
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now