yballan
asked on
ACCDE file error
Dear Experts,
I have created an application using my Access 2010 (14.0.7106.5003) SP2 MSO.
Problem occurs when I create ACCDE file, then try to run it on another 32-bit machine with Access 2010 runtime environment.
The error message is
" The database cannot be opened because the VBA project contained in it cannot be read. "
and more info on how it is going to delete the VBA project, etc.
From what I looked up on Internet, this occurs with version confusion, but I am using 32-bit Access to develop and compile, and downloaded 32-bit Access 2010 Runtime to run it on the other PC, so I think I matched the version. Clearly, I am doing something wrong.
Please advise.
I have created an application using my Access 2010 (14.0.7106.5003) SP2 MSO.
Problem occurs when I create ACCDE file, then try to run it on another 32-bit machine with Access 2010 runtime environment.
The error message is
" The database cannot be opened because the VBA project contained in it cannot be read. "
and more info on how it is going to delete the VBA project, etc.
From what I looked up on Internet, this occurs with version confusion, but I am using 32-bit Access to develop and compile, and downloaded 32-bit Access 2010 Runtime to run it on the other PC, so I think I matched the version. Clearly, I am doing something wrong.
Please advise.
ASKER
ASKER
Sorry, I think the resolution is not good, I just attached it without embedding this time.
Untitled.png
Untitled.png
First, make a backup of your database.
Remove any references that you don't need. If you can compile your database without the referenced checked, it is pretty sure that you don't need it.
Try a decompile. Details are here: http://peterssoftware.com/t_fixerr.htm , item "f.".
Post back if the problem persists.
Remove any references that you don't need. If you can compile your database without the referenced checked, it is pretty sure that you don't need it.
Try a decompile. Details are here: http://peterssoftware.com/t_fixerr.htm , item "f.".
Post back if the problem persists.
ASKER
Dear pdebaets,
I removed all but Visual Basic For Applications & Microsoft Access 14.0 Object Library.
When I tried to compile, I got an error on
Dim fd As FileDialog
What disturbed me was that when I looked up FileDialog, I found this on Microsoft site:
Note The FileDialog method works only in the full retail version of Microsoft Access. This method does not work in a Microsoft Access run-time application.
(http://support.microsoft.com/kb/824272)
Does this mean that in order to run my code, my users must purchase full retail version of Access? I rely on this function to allow a user to pick graphics files, which is extremely important.
Thank you for your help.
I removed all but Visual Basic For Applications & Microsoft Access 14.0 Object Library.
When I tried to compile, I got an error on
Dim fd As FileDialog
What disturbed me was that when I looked up FileDialog, I found this on Microsoft site:
Note The FileDialog method works only in the full retail version of Microsoft Access. This method does not work in a Microsoft Access run-time application.
(http://support.microsoft.com/kb/824272)
Does this mean that in order to run my code, my users must purchase full retail version of Access? I rely on this function to allow a user to pick graphics files, which is extremely important.
Thank you for your help.
The FileDialog is part of the Office library, so your user would need a full version of Office on the machine (not necessarily Access, however).
You can use API calls to allow the user to pick a file. API calls work with the Windows subsystem, not Office, so they'll work regardless of what's installed.
http://access.mvps.org/access/api/api0001.htm
Here's the MSDN example:
http://support.microsoft.com/kb/161286
I adapted the above to VBA below:
Dim sFile as String
sFile = GetFileName(Me.hWnd)
Msgbox sFile
You could adapt this so that you could pass in the initial directory, the dialog title, etc.
You can use API calls to allow the user to pick a file. API calls work with the Windows subsystem, not Office, so they'll work regardless of what's installed.
http://access.mvps.org/access/api/api0001.htm
Here's the MSDN example:
http://support.microsoft.com/kb/161286
I adapted the above to VBA below:
Option Compare Database
Option Explicit
Private Declare Function GetOpenFileName Lib "comdlg32.dll" Alias _
"GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long
Private Type OPENFILENAME
lStructSize As Long
hwndOwner As Long
hInstance As Long
lpstrFilter As String
lpstrCustomFilter As String
nMaxCustFilter As Long
nFilterIndex As Long
lpstrFile As String
nMaxFile As Long
lpstrFileTitle As String
nMaxFileTitle As Long
lpstrInitialDir As String
lpstrTitle As String
flags As Long
nFileOffset As Integer
nFileExtension As Integer
lpstrDefExt As String
lCustData As Long
lpfnHook As Long
lpTemplateName As String
End Type
Function GetFileName(OwnerHwn As Long) As String
Dim stOpenFile As OPENFILENAME
Dim ret As Long
Dim sfilter As String
With stOpenFile
.lStructSize = Len(stOpenFile)
.hwndOwner = OwnerHwn
.hInstance = Application.hWndAccessApp
sfilter = "Text files (*.txt)" & Chr(0) & "*.txt" & Chr(0)
.lpstrFilter = sfilter
.nFilterIndex = 1
.nMaxFile = Len(.lpstrFile) - 1
.lpstrInitialDir = "C:\"
.lpstrTitle = "Choose File"
ret = GetOpenFileName(stOpenFile)
Dim sRet As String
If ret <> 0 Then
sRet = Trim(.lpstrFile)
Else
sRet = "Cancel"
End If
End With
GetFileName = sRet
End Function
To use that, copy the code above into a new, standard module. Name the module something like "basFileDialog". then save it. To use it, call it like this, perhaps in the Click event of a button:Dim sFile as String
sFile = GetFileName(Me.hWnd)
Msgbox sFile
You could adapt this so that you could pass in the initial directory, the dialog title, etc.
ASKER
Dear Mr. McDaniel,
What a relief to hear that!! Thank you for the detailed instructions, I will try it immediately.
After this issue is solved, I will get back to my original issue, but I am hoping that this was the root cause of it.
I will keep you posted.
What a relief to hear that!! Thank you for the detailed instructions, I will try it immediately.
After this issue is solved, I will get back to my original issue, but I am hoping that this was the root cause of it.
I will keep you posted.
ASKER
Hello,
I recompiled with the FileDialog removed, and with only 3 references:
Visual Basic For Applications
Microsoft Access 14.0 Object Library
Microsoft Office 14.0 Access database engine Object Library.
But I still get the same error message, "The database cannot be opened because the VBA project..."
Please advise. Thank you.
I recompiled with the FileDialog removed, and with only 3 references:
Visual Basic For Applications
Microsoft Access 14.0 Object Library
Microsoft Office 14.0 Access database engine Object Library.
But I still get the same error message, "The database cannot be opened because the VBA project..."
Please advise. Thank you.
Is Office installed on the target machine?
ASKER
No, do I need Office 2010?
I have Office 2007 (Word, Excel). Should I install that?
I have Office 2007 (Word, Excel). Should I install that?
Are you opening the database file from a trusted location?
ASKER
Dear pdebaets,
How can I add the folder to the trusted location with just Access runtime?
I don't see option menu when I open my application.
How can I add the folder to the trusted location with just Access runtime?
I don't see option menu when I open my application.
ASKER
Dear Experts,
I just did a small test, I created an ACCDB file, containing a table with one field, then created a form with the field, then a button.
I wrote a blank VB script for the button, then compiled and created ACCDE.
When I try to run it on my target machine, it does not give me an error, just the security warning, but then there is no form or table.
I am getting very confused, please help.
I just did a small test, I created an ACCDB file, containing a table with one field, then created a form with the field, then a button.
I wrote a blank VB script for the button, then compiled and created ACCDE.
When I try to run it on my target machine, it does not give me an error, just the security warning, but then there is no form or table.
I am getting very confused, please help.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Note that the value in <my app> in Peter's suggestion above must be unique on the machine, so be aware of that.
ASKER
Yes!!!! It finally works! Thank you both very much!!!!
Can you perhaps list the References in your database? You can view these by opening the VBA Editor, then click Tools - References, and take a screenshot of the reference listing.