UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Compile Error, Access 2016    
 
   
mike60smart
post Oct 11 2019, 02:08 PM
Post#1


UtterAccess VIP
Posts: 13,397
Joined: 6-June 05
From: Dunbar,Scotland


Hi Everyone

How would I edit the Function highlighted so that it would work on 64 Bit OS ??

Any help appreciated.

Attached File  Error.PNG ( 44.87K )Number of downloads: 10

--------------------
Hope this helps?

Mike

Get happiness out of your work or you may never know what happiness is.

Go to the top of the page
 
arnelgp
post Oct 11 2019, 02:10 PM
Post#2



Posts: 1,424
Joined: 2-April 09
From: somewhere out there...


CODE
#If VBA7 Then
    Private Declare PtrSafe Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
    ( _
            ByVal hWnd As LongPtr, _
            ByVal lpOperation As String, _
            ByVal lpFile As String, _
            ByVal lpParameters As String, _
            ByVal lpDirectory As String, _
            ByVal nShowCmd As Long _
    ) As LongPtr
#Else
    Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
    ( _
            ByVal hwnd As Long, _
            ByVal lpOperation As String, _
            ByVal lpFile As String, _
            ByVal lpParameters As String, _
            ByVal lpDirectory As String, _
            ByVal nShowCmd As Long _
    ) As Long
#End If

This post has been edited by arnelgp: Oct 11 2019, 02:17 PM

--------------------
Never stop learning, because life never stops teaching.
Go to the top of the page
 
mike60smart
post Oct 11 2019, 02:30 PM
Post#3


UtterAccess VIP
Posts: 13,397
Joined: 6-June 05
From: Dunbar,Scotland


Hi Arnelgp

That fixed that piece of code

I now have the following error when I click a Command Button to browse to locate a File.

Any help appreciated.

Attached File  Error.PNG ( 25.67K )Number of downloads: 9

--------------------
Hope this helps?

Mike

Get happiness out of your work or you may never know what happiness is.

Go to the top of the page
 
arnelgp
post Oct 11 2019, 02:45 PM
Post#4



Posts: 1,424
Joined: 2-April 09
From: somewhere out there...


add Reference to Microsoft Office XX.X Object Library in VBE.

--------------------
Never stop learning, because life never stops teaching.
Go to the top of the page
 
tina t
post Oct 11 2019, 02:51 PM
Post#5



Posts: 6,107
Joined: 11-November 10
From: SoCal, USA


hi Mike, since you're using A2016, you might want to use

Application.FileDialog

instead, hon. you can read up on it here.

hth
tina

--------------------
"the wheel never stops turning"
Go to the top of the page
 
mike60smart
post Oct 11 2019, 03:10 PM
Post#6


UtterAccess VIP
Posts: 13,397
Joined: 6-June 05
From: Dunbar,Scotland


Hi Arnelgp

I already have it set ??

--------------------
Hope this helps?

Mike

Get happiness out of your work or you may never know what happiness is.

Go to the top of the page
 
mike60smart
post Oct 11 2019, 03:23 PM
Post#7


UtterAccess VIP
Posts: 13,397
Joined: 6-June 05
From: Dunbar,Scotland


Hi Tina

I tried using the example provided as shown below but I get the following error:-

Attached File  Error.PNG ( 3.13K )Number of downloads: 0


CODE
'Add a new attachment to the database
Private Sub cmd_LocateFile_Click()
    On Error GoTo Error_Handler
    ' Requires reference to Microsoft Office 11.0 Object Library.

   Dim fDialog As Office.FileDialog
   Dim varFile As Variant

   ' Clear listbox contents.
   Me.FileList.RowSource = ""

   ' Set up the File Dialog.
   Set fDialog = Application.FileDialog(msoFileDialogFilePicker)

   With fDialog

      ' Allow user to make multiple selections in dialog box
      .AllowMultiSelect = True
            
      ' Set the title of the dialog box.
      .Title = "Please select one or more files"

      ' Clear out the current filters, and add our own.
      .Filters.Clear
      .Filters.Add "Access Databases", "*.MDB"
      .Filters.Add "Access Projects", "*.ADP"
      .Filters.Add "All Files", "*.*"

      ' Show the dialog box. If the .Show method returns True, the
      ' user picked at least one file. If the .Show method returns
      ' False, the user clicked Cancel.
      If .Show = True Then

         'Loop through each file selected and add it to our list box.
         For Each varFile In .SelectedItems
            Me.FileList.AddItem varFile
         Next

      Else
         MsgBox "You clicked Cancel in the file dialog box."
      End If
   End With
End Sub


It Highlights this line:-
Attached File  Error.PNG ( 3.13K )Number of downloads: 0


Attached File(s)
Attached File  Error.PNG ( 17.77K )Number of downloads: 6
 

--------------------
Hope this helps?

Mike

Get happiness out of your work or you may never know what happiness is.

Go to the top of the page
 
tina t
post Oct 11 2019, 04:17 PM
Post#8



Posts: 6,107
Joined: 11-November 10
From: SoCal, USA


hello, Mike, i suggested

Application.FileDialog

hon, not Office.FileDialog. the link in my previous post goes to Microsoft's Office VBA reference for Access.

hth
tina

--------------------
"the wheel never stops turning"
Go to the top of the page
 
mike60smart
post Oct 12 2019, 05:32 AM
Post#9


UtterAccess VIP
Posts: 13,397
Joined: 6-June 05
From: Dunbar,Scotland


Hi Tina & Arnelgp

I have resolved this by using the example Db where the code is working.

Copied this Db and then Imported my Dev Db into it.

Now works OK

Strange how the same code from the example Db would not work in my Dev Db.

Thanks for looking
cheers.gif kisses.gif

--------------------
Hope this helps?

Mike

Get happiness out of your work or you may never know what happiness is.

Go to the top of the page
 
tina t
post Oct 12 2019, 09:57 AM
Post#10



Posts: 6,107
Joined: 11-November 10
From: SoCal, USA


hello, Mike, good job finding a way to make it work for you. as for the strangeness, i just chalk that up to the joys of A2016. :( tina

--------------------
"the wheel never stops turning"
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    15th October 2019 - 04:32 AM