0
votes

I have an app created in access 2010 64 bit. I have since replaced access 2010 64 bit with access 2013 32 bit on the same PC. The app works fine in both versions of access as an accdb file but when I attempt to create an accde file I receive an error "access unable to create an accde file" - this didn't happen in the access 2010 accde version.

I plan to distribute the app using access 2013 runtime. In one case I thought the problem might be related to late binding but I think that's illogical now.

In the below code the compilation stops at "Dim fldr as Office.FileDialogue" with the message "user defined type not defined" (there is a similar error elsewhere too).

 Public Function GetFolderName(Optional OpenAt As String) As String

 Dim lCount As Long
 Dim fldr As Office.FileDialog
 Set fldr = Application.FileDialog(msoFileDialogFolderPicker)
 GetFolderName = vbNullString

With fldr

.InitialFileName = OpenAt
.Show
For lCount = 1 To .SelectedItems.Count
    GetFolderName = .SelectedItems(lCount)
Next lCount
End With
End Function
1
Check for missing References from your VBA code window, in this case you're missing the Microsoft Office [version number] Object Library. See here for more info stackoverflow.com/questions/9476268/filedialog-doesnt-workjbud
it also stops in a different sub at "dim xx as table" which used to work in access 2010 but not in 2013, there are a lot of similar instances.Sputnik
I have set the reference to "Microsoft Office 15 Object Library" but produces the same error. You mentioned re-installing the object library but I don't know how. Thank you for your time.Sputnik
Where are you actually getting the error now? At the same Dim fldr as Office.FileDialogue? You need to see if you're missing any references, by opening the VBA window, then going to Tools --> References. See if any of the libraries are marked as missing.jbud
As for the Dim xx as Table, what type of table are your referring to in your code?jbud

1 Answers

0
votes

Try this

Public Function GetFolderName(Optional OpenAt As String) As String

 Dim lCount As Long
 Dim fldr As Object
 Set fldr = Application.FileDialog(4)
 GetFolderName = vbNullString

With fldr

.InitialFileName = OpenAt
.Show
For lCount = 1 To .SelectedItems.Count
    GetFolderName = .SelectedItems(lCount)
Next lCount
End With
End Function

See this link for the MsoFileDialogType enumeration: https://docs.microsoft.com/en-us/office/vba/api/office.msofiledialogtype