Visual Studio 2005
VB 2005
Windows Application
I have a form with one combo box and a button
I want the user to make a selection from the combo box, click the button and have the application run an Access 2003 Macro, the database is embedded in my project.
I receive the following message when the button is clicked:
Microsoft Office Access can't open the database because it is missing, or opened exclusively by another user
The problem must be with the filepath in my code here is the code under the button click event:
Expand|Select|Wrap|Line Numbers
- Select Case ComboBox1.SelectedItem
- Case "Clear Form"
- Dim oAccess As Access.ApplicationClass
- 'Start Access and open the database.
- oAccess = CreateObject("Access.Application")
- oAccess.Visible = False
- oAccess.OpenCurrentDatabase("|DataDirectory|LTDatabase.mdb", False)
- 'Run the macro
- 'oAccess.Run("test2")
- 'Clean-up: Quit Access without saving changes to the database.
- oAccess.DoCmd().Quit(Access.AcQuitOption.acQuitSaveNone)
- System.Runtime.InteropServices.Marshal.ReleaseComObject(oAccess)
- oAccess = Nothing
- End Select
- GC.Collect()
I'm sure it is something very basic that I'm missing....any thoughts would be appreciated.
Lone
UPDATE
It's just dawned on me that Access has no chance of finding "|DataDirectory|LTDatabase.mdb so how am I going to have this functionality in a deployed application mmmmmm scratching head