Solved

MS Access Open another database from current and close Current

Posted on 2016-09-30
5
39 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Outlook 2016 VB code syntax 4 35
GA Ribbon creator 9 59
Microsoft Access 32-bit or 64-bit? 11 56
Error message for incorrect or missing hyperlink 3 26
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Familiarize people with the process of utilizing SQL Server views 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 Microsoft Access…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

737 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