0

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
braX
  • 11,506
  • 5
  • 20
  • 33
Sputnik
  • 43
  • 7
  • 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 https://stackoverflow.com/questions/9476268/filedialog-doesnt-work – jbud Feb 19 '19 at 02:31
  • 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 Feb 19 '19 at 18:46
  • 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 Feb 19 '19 at 19:04
  • 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 Feb 19 '19 at 19:39
  • As for the `Dim xx as Table`, what type of table are your referring to in your code? – jbud Feb 19 '19 at 19:45
  • There are no missing references. The references are: Visual Basic for Applications Microsoft Access 15.0 Object Library Microsoft Office 15.0 Access database engine Object ... OLE Automation Microsoft Office 15.0 Object Library – Sputnik Feb 19 '19 at 22:58
  • The errors are the same as they were originally. – Sputnik Feb 19 '19 at 23:06
  • The table is a liked table in Quickbooks using QODBC but the fldr refers to an Office file dialogue. – Sputnik Feb 19 '19 at 23:24
  • jbud, The problem isn't just this function getfoldername it's a project wide general problem, I think you were on the right track with your initial References comment. – Sputnik Feb 20 '19 at 17:16
  • Unfortunately there's no easy upgrade track for your needs, you'll need to make updates to your code base to accommodate new versions of Access sooner or later. Especially if you're using third party libraries. – jbud Feb 20 '19 at 20:11
  • @jbud I have looked online for a new format for 'dim x as table' or general dim statements but found nothing. Where can I find a reference to code base updates? I don't think I am using third party libraries. – Sputnik Feb 22 '19 at 17:46
  • I cannot find any reference to the `Table` data type in the online documents. That's why I figured it might be coming from a third party library. You need to find out from which library it's coming. – jbud Feb 22 '19 at 18:06

1 Answers1

0

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://learn.microsoft.com/en-us/office/vba/api/office.msofiledialogtype

jbud
  • 694
  • 5
  • 7
  • in references in access 2010 there is a reference "Utility" which is not in access 2013 -could this be the problem? – Sputnik Feb 20 '19 at 17:49
  • I renamed my getfoldername and inserted your getfoldername code, Your code for getfoldername compiled but so did my renamed getfoldernameX. I also repaired ms office prior to using your code but that changed nothing. I tried renaming the btnsave_click but that didn't compile, ms says 'dim x as table' is a valid expression. – Sputnik Feb 21 '19 at 18:14
  • I agree that `dim x as table` is a valid expression. My point is that the type `Table` is referring to a library which it can't find during compilation. This is causing your compile issues, and then causing the accde build to fail. You need to reference all the required libraries in your code/references to get a successful build. If this code is not being used, then you can comment it out and see if the build succeeds. – jbud Feb 21 '19 at 18:47