Solved

MS Access Open another database from current and close Current

Posted on 2016-09-30
5
37 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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

735 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