FrozenMana
Registered User.
- Local time
- Today, 15:40
- Joined
- Aug 10, 2015
- Messages
- 27
I have a database that was created to be used with 32-bit system of MS Access.
However the user who currently needs to utlitize this database has the 64-bit version of Office including Access. The user has been having many issues since this upgrade occured.
I added the PtrSate between Declare and Function as well as chaning Long to LongPtr. However I am now getting a complie error stating a type mismatch. My apologizes if this issue is obvious as I am still learning vba.
Error message highlights and adds arrow to the yellow and also highlights in blue the blue font:
Any help is much appriciated, thank you in advance.
However the user who currently needs to utlitize this database has the 64-bit version of Office including Access. The user has been having many issues since this upgrade occured.
I added the PtrSate between Declare and Function as well as chaning Long to LongPtr. However I am now getting a complie error stating a type mismatch. My apologizes if this issue is obvious as I am still learning vba.
Code:
Option Compare Database
Private Type BROWSEINFO
hOwner As LongPtr
pidlRoot As LongPtr
pszDisplayName As String
lpszTitle As String
ulFlags As Long
lpfn As LongPtr
lParam As LongPtr
iImage As Long
End Type
Private Declare PtrSafe Function SHGetPathFromIDList Lib "shell32.dll" Alias _
"SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As LongPtr
Private Declare PtrSafe Function SHBrowseForFolder Lib "shell32.dll" Alias _
"SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As LongPtr
Private Const BIF_RETURNONLYFSDIRS = &H1
Public Function BrowseFolder(szDialogTitle As String) As String
Dim X As Long, bi As BROWSEINFO, dwIList As Long
Dim szPath As String, wPos As Integer
With bi
.hOwner = hWndAccessApp
.lpszTitle = szDialogTitle
.ulFlags = BIF_RETURNONLYFSDIRS
End With
dwIList = SHBrowseForFolder(bi)
szPath = Space$(512)
X = SHGetPathFromIDList(ByVal dwIList, ByVal szPath)
If X Then
wPos = InStr(szPath, Chr(0))
BrowseFolder = Left$(szPath, wPos - 1)
Else
BrowseFolder = vbNullString
End If
End Function
Private Sub btnBrowseForFolder_Click()
Me.txtFolderString = BrowseFolder("Hello, " & UCase(Left(WindowsLogOn, 1)) & " " & UCase(Mid(WindowsLogOn, 2, 1)) & Right(WindowsLogOn, Len(WindowsLogOn) - 2) & ". Please Choose the folder where your excel files are located")
End Sub
Private Sub cmdGO_Click()
Call importFiles
Call exportFiles
Me.txtFolderString = ""
End Sub
Error message highlights and adds arrow to the yellow and also highlights in blue the blue font:
Code:
[COLOR="Yellow"][B][U]-> Public Function BrowseFolder(szDialogTitle As String) As String[/U][/B][/COLOR]
Dim X As Long, bi As BROWSEINFO, dwIList As Long
Dim szPath As String, wPos As Integer
With bi
.hOwner = hWndAccessApp
.lpszTitle = szDialogTitle
.ulFlags = BIF_RETURNONLYFSDIRS
End With
dwIList = [COLOR="RoyalBlue"][B][U]SHBrowseForFolder[/U][/B][/COLOR](bi)
szPath = Space$(512)
X = SHGetPathFromIDList(ByVal dwIList, ByVal szPath)
If X Then
wPos = InStr(szPath, Chr(0))
BrowseFolder = Left$(szPath, wPos - 1)
Else
BrowseFolder = vbNullString
End If
End Function
Any help is much appriciated, thank you in advance.
Last edited: