Solved

MS Access Open another database from current and close Current

Posted on 2016-09-30
5
27 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
ID: 41823770
Did you try docmd.quit after all your other code
0
 

Author Comment

by:Taras
ID: 41823930
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
ID: 41824130
DID DOCMD.QUIT WORK?
0
 

Author Comment

by:Taras
ID: 41824141
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
ID: 41824212
Thank you
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

929 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

19 Experts available now in Live!

Get 1:1 Help Now