Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Declare Function DeleteUrlCacheEntry 64 bit system

Posted on 2014-01-20
6
Medium Priority
?
1,627 Views
Last Modified: 2014-01-23
I am using the following function in one of my databases that needs to run on both 32 bit and 64 bit systems. Two questions:
1)   Is there any way to modify it so it will run on both, or do I need different front ends for each version?
2)  What do I need to do to make it run on a 64 bit version of MS Access (2010)?

Private Declare Function DeleteUrlCacheEntry Lib "wininet" Alias _
    "DeleteUrlCacheEntryA" (ByVal lpszUrlName As String) As Long

Private Declare Function URLDownloadToFile Lib "urlmon" Alias _
"URLDownloadToFileA" (ByVal pCaller As Long, _
ByVal szURL As String, _
ByVal szFileName As String, _
ByVal dwReserved As Long, _
ByVal lpfnCB As Long) As Long
0
Comment
Question by:Rob4077
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 12

Accepted Solution

by:
pdebaets earned 2000 total points
ID: 39793738
You can use the VBA7 compiler directive constant to determine which block of code to compile in the different environments.

Try this:

#if VBA7 then
    Private Declare PtrSafe Function DeleteUrlCacheEntry Lib "wininet" Alias _
        "DeleteUrlCacheEntryA" (ByVal lpszUrlName As String) As Long

    Private Declare PtrSafe Function URLDownloadToFile Lib "urlmon" Alias _
    "URLDownloadToFileA" (ByVal pCaller As LongPtr, _
    ByVal szURL As String, _
    ByVal szFileName As String, _
    ByVal dwReserved As Long, _
    ByVal lpfnCB As LongPtr) As LongPtr
#else
    Private Declare Function DeleteUrlCacheEntry Lib "wininet" Alias _
        "DeleteUrlCacheEntryA" (ByVal lpszUrlName As String) As Long

    Private Declare Function URLDownloadToFile Lib "urlmon" Alias _
    "URLDownloadToFileA" (ByVal pCaller As Long, _
    ByVal szURL As String, _
    ByVal szFileName As String, _
    ByVal dwReserved As Long, _
    ByVal lpfnCB As Long) As Long
#end if

Open in new window

0
 

Author Comment

by:Rob4077
ID: 39793869
That appears to work on my 32 bit version at home. I will confirm it on the 64 bit version at the office tomorrow before I close the question. Thanks very much for your help
0
 
LVL 12

Expert Comment

by:pdebaets
ID: 39794549
Your URLDownloadToFile function will return a LongPtr value in Access 2010. So you may need additional code changes such as

#if VBA7 then
dim ReturnVal as LongPtr
#Else
dim ReturnVal as Long
#end if

ReturnVal = URLDownloadToFile(...
0
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 

Author Comment

by:Rob4077
ID: 39795729
Can I just change it to Single instead of LongPtr/Long ?
0
 
LVL 12

Expert Comment

by:pdebaets
ID: 39795823
No.
0
 

Author Comment

by:Rob4077
ID: 39802858
All works perfectly. Thanks.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question