manasvi wants to close the database only but the Microsoft access application is closing. suggest her the correct method
to do it
Answers
Answer:
your answer is here
Explanation:
You can use the CloseCurrentDatabase method to close the current database, either a Microsoft Access database or an Access project (.adp) from another application that has opened a database through Automation.
The following example opens a Microsoft Access database from another application through Automation, creates a new form and saves it, and then closes the database.
You can enter this code in a Visual Basic module in any application that can act as a COM component. For example, you might run the following code from Microsoft Excel or Microsoft Visual Basic.
When the variable pointing to the Application object goes out of scope, the instance of Microsoft Access that it represents closes as well. Therefore, you should declare this variable at the module level.
VB
' Enter the following in the Declarations section of the module.
Dim appAccess As Access.Application
Sub CreateForm()
Const strConPathToSamples = "C:\Program Files\Microsoft Office\Office12\Samples\"
Dim frm As Form, strDB As String
' Initialize string to database path.
strDB = strConPathToSamples & "Northwind.mdb"
' Create new instance of Microsoft Access.
Set appAccess = CreateObject("Access.Application")
' Open database in Microsoft Access window.
appAccess.OpenCurrentDatabase strDB
' Create new form.
Set frm = appAccess.CreateForm
' Save new form.
appAccess.DoCmd.Save , "NewForm1"
' Close currently open database.
appAccess.CloseCurrentDatabase
Set AppAccess = Nothing
End Subion that has opened a database through Automation.