Ask a Question

Test form inside Microsoft Access accdb file Error

SOLVED
Alexdaner
New Contributor

Test form inside Microsoft Access accdb file Error

When I'm trying to open database using OpenCurrentDatabase method - I'm getting error.
I need to test forms. Not change DB. Check functionality of the form.

Code:

 

 

function Acess_Test() {
    MsAccess = Sys.OleObject("Access.Application");
    MsAccess.Visible = true;
    FileName = "C:\Public\Database2.accdb";
    MsAccess.OpenCurrentDatabase(FileName);
}

 

 

Error: 

Alexdaner_0-1654404142303.png

On this PC code from Excel VBA - works well:

 

 

Sub MyFunc()
    Dim appAccess As New Access.Application
    appAccess.OpenCurrentDatabase ("C:\Public\Database2.accdb")
    appAccess.Visible = True
End Sub

 

 

 

2 REPLIES 2
rraghvani
Frequent Contributor

Use double backslash when referring to file path,

 

function Acess_Test() {
    MsAccess = Sys.OleObject("Access.Application");
    MsAccess.Visible = true;
    FileName = "C:\\Public\\Database2.accdb"; // <-- Use double backslash
    MsAccess.OpenCurrentDatabase(FileName);
}
Alexdaner
New Contributor

For me forward slash works also well.

cancel
Showing results for 
Search instead for 
Did you mean: