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

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
> Removing Ptrsafe, Access 2016    
 
   
Knuckles
post Oct 17 2019, 10:25 AM
Post#1



Posts: 911
Joined: 1-February 10
From: New Jersey



Greetings UA,

I inherited a few 32 bit databases.
Added ptrsafe and they seem to run ok on my machine with O365.

Since not all users have been upgraded to O365 we thought we could have parallel front ends pointing to the same back end. That's when something unexpected happened...

A 32 bit user was able to open the front end successfully.
I got an error that came up in a loop "Cannot open any more databases"
I then removed ptrsafe from mine and passed the front end back to the 32 bit user that successfully opened it before and he now got the same error message.

Is that to be expected? Is it not possible to go back once opened in O365?

This is the tip of the iceberg so any direction would be much appreciated.
Thank you in advance.

Knuckles

Go to the top of the page
 
Start new topic
Replies
arnelgp
post Oct 17 2019, 10:48 AM
Post#2



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


same access version (32 or 64), there won't be any problem.
newer version has newer system tables.
so older version will complain about it.

for compatibility enclosed all your api in:

#If VBA7
Private Ptrsafe Function
#Else
Private Function
#End If

use Currentdb instead of Dbengine(0)(0) on your code.
and always destroy (set db = Nothing), when exiting
from any sub/func, to eliminate the error.

--------------------
Never stop learning, because life never stops teaching.
Go to the top of the page
 
Knuckles
post Oct 17 2019, 10:58 AM
Post#3



Posts: 911
Joined: 1-February 10
From: New Jersey



I am running 64 bit.

The error is triggered by this line in a loop
strEmail = Nz(DLookup("[E-mail]", "tbl_UserSecurity", "[Person_Name] = '" & rst.Fields("Requester") & "'"), "")

looks like it failed on the 12th iteration.

Is this correct?
If VBA7 Then
Declare PtrSafe Function SetWindowPos Lib "user32" (ByVal hwnd As Long, _
ByVal hWndInsertAfter As Long, _
ByVal x As Long, _
ByVal y As Long, _
ByVal cx As Long, _
ByVal cy As Long, _
ByVal wFlags As Long) As Long
Else
Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, _
ByVal hWndInsertAfter As Long, _
ByVal x As Long, _
ByVal y As Long, _
ByVal cx As Long, _
ByVal cy As Long, _
ByVal wFlags As Long) As Long
End If
Go to the top of the page
 
isladogs
post Oct 17 2019, 11:02 AM
Post#4


UtterAccess VIP
Posts: 1,895
Joined: 4-June 18
From: Somerset, UK


Run a debug.print aster the strEmail line in the loop.
Check the available connections as suggested.

Changes needed
Use # before If, Else, End if in the conditional compilation
Use LongPtr for both hWnd items in the VBA7 part

--------------------
Colin (Mendip Data Systems)
Website, email
Go to the top of the page
 
arnelgp
post Oct 17 2019, 11:11 AM
Post#5



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


CODE
#If VBA7 Then
    Declare PtrSafe Function SetWindowPos Lib "user32" (ByVal hwnd As LongPtr, _
             ByVal hWndInsertAfter As LongPtr, _
             ByVal x As Long, _
             ByVal y As Long, _
             ByVal cx As Long, _
             ByVal cy As Long, _
             ByVal wFlags As Long) As Long
#Else
    Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, _
             ByVal hWndInsertAfter As Long, _
             ByVal x As Long, _
             ByVal y As Long, _
             ByVal cx As Long, _
             ByVal cy As Long, _
             ByVal wFlags As Long) As Long
#End If

This post has been edited by arnelgp: Oct 17 2019, 11:12 AM

--------------------
Never stop learning, because life never stops teaching.
Go to the top of the page
 
Knuckles
post Oct 17 2019, 11:19 AM
Post#6



Posts: 911
Joined: 1-February 10
From: New Jersey


Everything turned red and I got a compile error on the second # in the first line.
Go to the top of the page
 
arnelgp
post Oct 17 2019, 11:22 AM
Post#7



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


it will turn red on x64 office, that is fine.

--------------------
Never stop learning, because life never stops teaching.
Go to the top of the page
 
Knuckles
post Oct 17 2019, 11:23 AM
Post#8



Posts: 911
Joined: 1-February 10
From: New Jersey



what about the compile error?
Go to the top of the page
 
arnelgp
post Oct 17 2019, 11:27 AM
Post#9



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


leave as-is "user32"

--------------------
Never stop learning, because life never stops teaching.
Go to the top of the page
 
Knuckles
post Oct 17 2019, 01:30 PM
Post#10



Posts: 911
Joined: 1-February 10
From: New Jersey


I have gone through all the declarations and I am now getting a "mismatch" on WNetGetUser

' Get the log-on name of the person using product.
Status = WNetGetUser(lpName, lpUserName, lpnLength)

Is there more to it than just modifying the declarations?

#If VBA7 Then
Declare PtrSafe Function WNetGetUser Lib "mpr.dll" _
Alias "WNetGetUserA" (ByVal lpName As String, _
ByVal lpUserName As String, lpnLength As Long) As LongPtr
#Else
Declare Function WNetGetUser Lib "mpr.dll" _
Alias "WNetGetUserA" (ByVal lpName As String, _
ByVal lpUserName As String, lpnLength As Long) As Long
#End If
This post has been edited by Knuckles: Oct 17 2019, 01:32 PM
Go to the top of the page
 
isladogs
post Oct 17 2019, 01:42 PM
Post#11


UtterAccess VIP
Posts: 1,895
Joined: 4-June 18
From: Somerset, UK


I believe the first part should with As Long and not As LongPtr

How are you doing these conversions? Are you looking them up or just hazarding a 'guess'

--------------------
Colin (Mendip Data Systems)
Website, email
Go to the top of the page
 
Knuckles
post Oct 17 2019, 01:49 PM
Post#12



Posts: 911
Joined: 1-February 10
From: New Jersey



Let's just say I am in water well over my head...
Go to the top of the page
 
isladogs
post Oct 17 2019, 02:14 PM
Post#13


UtterAccess VIP
Posts: 1,895
Joined: 4-June 18
From: Somerset, UK


QUOTE
Let's just say I am in water well over my head...


Two suggestions:
1. Install the Windows API Viewer which covers the 32-bit/64-bit conversions for most common APIs. Unfortunately not all.
2. Read articles explaining how to do such conversions e.g. one by Phillip Stiefel at https://codekabinett.com/rdumps.php?Lang=2&...tion-vba-64-bit
Also read the linked articles by MS including https://docs.microsoft.com/en-gb/office/vba...ations-overview

Hope that helps you move forward

--------------------
Colin (Mendip Data Systems)
Website, email
Go to the top of the page
 
Knuckles
post Oct 17 2019, 02:18 PM
Post#14



Posts: 911
Joined: 1-February 10
From: New Jersey


I'm on it. Thanks.
Go to the top of the page
 
BruceM
post Oct 18 2019, 10:08 AM
Post#15


UtterAccess VIP
Posts: 7,993
Joined: 24-May 10
From: Downeast Maine


Just to clarify (I don't think it has been mentioned), the VBA7 conditional compilation is needed only if there are Access versions 2007 or earlier. 2010 and later versions of Access use VBA 7, so you can just use the declaration that appears under the VBA7 banner, and eliminate the rest (and get rid of the number sign).

Some variables (in API declarations in particular) indicate memory locations, which are typically referred to as pointers or handles. These memory locations are 32-bit in a 32-bit version of Access, and 64-bit in a 64-bit version. A variable such as hWnd is almost surely such a variable. In a 32-bit version of Access 2010 or later it works to use Long instead of LongPtr, since Long (a 32-bit data type) is the same size as the memory location. However, with a 64-bit version of Access the program doesn't know what to do if a 32-bit value references a 64-bit memory location. To anthropomorphize, it says "Where's the rest of it? I can't proceed until I have the rest".

Declaring a function as PtrSafe means it is ready to accept memory location variables (it is safe to do so). Then when the variable is LongPtr, Access allocates either passes a 32-bit Long value to the memory location or first converts it to LongLong, a 64-bit value that can express a value in the quintillions, I believe, but can also express any value that can be expressed as Long. It doesn't work the other way around, though. A LongLong value cannot be used in a 32-bit Office application. I have not yet had a use for LongLong, but I doubt it is used often outside of specialized situations.

Procedure documentation for APIs should include information about conditional compilation needs, but I will just point out that there are a very few and rather uncommon APIs where it makes any difference if it is a 32-bit or 64-bit version of Office. This is to say the #If Win64 conditional compilation is rarely needed as long as PtrSafe and LongPtr are used.
Go to the top of the page
 
PhilS
post Oct 18 2019, 12:21 PM
Post#16



Posts: 651
Joined: 26-May 15
From: The middle of Germany


QUOTE
To anthropomorphize, it says "Where's the rest of it? I can't proceed until I have the rest".

Not quite. It has no clue all those zeroes in the upper half of the Int64 are not there intentionally. It will read or write the memory at the partial address and then, after some weird effects happened, tell you: "How should I have known you gave me only half an address?"
This post has been edited by PhilS: Oct 18 2019, 12:54 PM

--------------------
Go to the top of the page
 
Knuckles
post Oct 18 2019, 12:25 PM
Post#17



Posts: 911
Joined: 1-February 10
From: New Jersey



Thank you all for your guidance. I am on my way and I now have some good resources.

One last question (for now)...

If I miss adding ptr to a long that should have had it will it bark at me and let me know?

Knuckles
Go to the top of the page
 
isladogs
post Oct 18 2019, 03:10 PM
Post#18


UtterAccess VIP
Posts: 1,895
Joined: 4-June 18
From: Somerset, UK


QUOTE
If I miss adding ptr to a long that should have had it will it bark at me and let me know?


Unfortunately not. Nor will it tell you when you've used longptr incorrectly instead of long
You need to remember that just because PtrSafe allows the code to compile in 64-bit, unless you assign Long/LongPtr where necessary, the code will not actually work correctly.
Using references such as those Bruce & I provided are definitely your best support in this process

I agree with Bruce's comments about only needing conditional compilation where you have users running A2007 or earlier.
However, I always use it as a lot of my clients still run older versions and because I publish many example apps online

--------------------
Colin (Mendip Data Systems)
Website, email
Go to the top of the page
 
Knuckles
post Oct 18 2019, 03:15 PM
Post#19



Posts: 911
Joined: 1-February 10
From: New Jersey



Thanks Colin. I guess I won't really know until some users get in there.
These databases have been around for 12 years or so and I have only gotten into them last week.
As far as I know I am the only one using 64 bit.
Go to the top of the page
 
isladogs
post Oct 18 2019, 03:23 PM
Post#20


UtterAccess VIP
Posts: 1,895
Joined: 4-June 18
From: Somerset, UK


It would obviously help to have at least 1 user on 64-bit!
Because I have to develop for both bitnesses, I have workstations running different versions including 32-bit A2010 (my main development PC) and 64-bit A2019/365.
If your apps are distributed as ACCDE files, you will need to create/distribute different versions for each bitness

ALSO:
Do remember that development should ALWAYS be done in the oldest Access version used by your clients - this is to prevent issues with VBA references

Are there still issues with 'cannot open any more databases errors'?

--------------------
Colin (Mendip Data Systems)
Website, email
Go to the top of the page
 
Knuckles
post Oct 18 2019, 03:29 PM
Post#21



Posts: 911
Joined: 1-February 10
From: New Jersey



The databases are all .accdb.
I don't think there was any consideration given to operating systems.

I started 2 weeks ago was given a cubicle and a computer. Didn't know there were any issues until I put my versions on the server.
Live and learn!

For whatever reason there are no more issues with the error message I was receiving.
Coincidentally I used a version of the front end that I converted yesterday.
Go to the top of the page
 
AlbertKallal
post Oct 18 2019, 06:30 PM
Post#22


UtterAccess VIP
Posts: 2,903
Joined: 12-April 07
From: Edmonton, Alberta Canada


Sounds like you are on your way.

Just as a FYI?
It not really the operating system choice that matters much here. Just about "everything" is x64 bits.

What matters of course is the version of Access (x32, or x64). As of late, I am seeing more x64 bit deployments of office.
(x64 bit versions of office used to be rather rare - but not so much anymore).


Regards,
Albert D. Kallal (Access MVP 2003-2017)
Edmonton, Alberta Canada
Go to the top of the page
 
Knuckles
post Oct 21 2019, 11:39 AM
Post#23



Posts: 911
Joined: 1-February 10
From: New Jersey


Greetings all and happy Monday,

We have been testing out the databases that have been converted and received this error message.

Error message:Run-time error '429':
ActiveX component can't create object

here is the code that triggered it...
Function RunProcessChain(ByVal ApplicationServer As String, ByVal Client As String, ByVal System As String, ByVal SystemNumber As String, ByVal UserName As String, ByVal PassWord As String, ByVal ProcessChainEvent As String, Optional TestConnection As Boolean = False) As Boolean
Dim SapBWApp As Object
Dim SapBWLogon, SapBWConnection, SapBWFunction, SapBWEventParamater As Object

RunProcessChain = False
Set SapBWLogon = CreateObject("SAP.Logoncontrol.1")

First question is did I miss something in the conversion that might be triggering this?
Second question is if that is not the case can anyone point me in the right direction? Do I need to start a new post?

Thanks in advance

Knuckles


Go to the top of the page
 
isladogs
post Oct 21 2019, 01:09 PM
Post#24


UtterAccess VIP
Posts: 1,895
Joined: 4-June 18
From: Somerset, UK


I believe the error occurs when the object already exists. In which case you 'get' it rather than create it.

Place the following code in your error handling routine for this procedure

CODE
If err 429 then
Set SAPBWLogon=GetObject(, "SAPLogonControl.1")
Resume Next
End If


This is air code so check for typos

--------------------
Colin (Mendip Data Systems)
Website, email
Go to the top of the page
 
cheekybuddha
post Oct 21 2019, 01:13 PM
Post#25


UtterAccess Moderator
Posts: 11,909
Joined: 6-December 03
From: Telegraph Hill


Either that, or the SAPLogonControl is not registered.

--------------------


Regards,

David Marten
Go to the top of the page
 
tina t
post Oct 21 2019, 01:16 PM
Post#26



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


PMFJI, guys, but i'm wondering about the following line, for my education as much as to help Knuckles:

CODE
Dim SapBWLogon, SapBWConnection, SapBWFunction, SapBWEventParamater As Object

am i right in thinking that the last variable is dimmed as an Object, but all the preceding ones are dimmed as Variant?

tia,
tina

--------------------
"the wheel never stops turning"
Go to the top of the page
 
isladogs
post Oct 21 2019, 01:19 PM
Post#27


UtterAccess VIP
Posts: 1,895
Joined: 4-June 18
From: Somerset, UK


Tina
You are correct. Each variable needs to be defined individually or they revert to variant.

--------------------
Colin (Mendip Data Systems)
Website, email
Go to the top of the page
 
tina t
post Oct 21 2019, 04:28 PM
Post#28



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


thanks, Colin and David. :) tina

--------------------
"the wheel never stops turning"
Go to the top of the page
 
Knuckles
post Oct 21 2019, 05:04 PM
Post#29



Posts: 911
Joined: 1-February 10
From: New Jersey


Thank you all, we are digging into SAP a bit.

Knuckles
Go to the top of the page
 

Posts in this topic
- Knuckles   Removing Ptrsafe   Oct 17 2019, 10:25 AM
- - nuclear_nick   Allow me to help you clarify your post... 1) O365...   Oct 17 2019, 10:44 AM
|- - isladogs   To add to Nick and arnel's comments, the way t...   Oct 17 2019, 10:55 AM
- - arnelgp   same access version (32 or 64), there won't be...   Oct 17 2019, 10:48 AM
- - Knuckles   I am running 64 bit. The error is triggered by th...   Oct 17 2019, 10:58 AM
- - isladogs   Run a debug.print aster the strEmail line in the l...   Oct 17 2019, 11:02 AM
|- - Knuckles   Thanks Colin, I will check out the available conne...   Oct 17 2019, 11:10 AM
|- - arnelgp   CODE#If VBA7 Then Declare PtrSafe Function SetWin...   Oct 17 2019, 11:11 AM
|- - Knuckles   Everything turned red and I got a compile error on...   Oct 17 2019, 11:19 AM
|- - isladogs   There should only be one # on the If line #If VBA7...   Oct 17 2019, 11:22 AM
|- - arnelgp   it will turn red on x64 office, that is fine.   Oct 17 2019, 11:22 AM
||- - Knuckles   what about the compile error?   Oct 17 2019, 11:23 AM
||- - arnelgp   leave as-is "user32"   Oct 17 2019, 11:27 AM
||- - Knuckles   I have gone through all the declarations and I am ...   Oct 17 2019, 01:30 PM
||- - isladogs   I believe the first part should with As Long and n...   Oct 17 2019, 01:42 PM
||- - Knuckles   Let's just say I am in water well over my head...   Oct 17 2019, 01:49 PM
||- - isladogs   QUOTE Let's just say I am in water well over m...   Oct 17 2019, 02:14 PM
||- - Knuckles   I'm on it. Thanks.   Oct 17 2019, 02:18 PM
|||- - BruceM   Just to clarify (I don't think it has been men...   Oct 18 2019, 10:08 AM
|||- - Knuckles   Thanks for the additional information Bruce. I am...   Oct 18 2019, 10:33 AM
||||- - arnelgp   #If VBA7 Then Private Declare PtrSafe Function SHF...   Oct 18 2019, 10:36 AM
||||- - Knuckles   It still gives me a mismatch. Might it be related...   Oct 18 2019, 10:39 AM
||||- - Knuckles   I found an extra longptr, Thank you.   Oct 18 2019, 10:51 AM
|||- - PhilS   QUOTE To anthropomorphize, it says "Where...   Oct 18 2019, 12:21 PM
|||- - Knuckles   Thank you all for your guidance. I am on my way a...   Oct 18 2019, 12:25 PM
||||- - BruceM   If you have 64-bit Office and are using APIs, or p...   Oct 18 2019, 12:56 PM
|||||- - Knuckles   Bruce, Thanks for the additional resources. As I...   Oct 18 2019, 03:06 PM
||||- - isladogs   QUOTE If I miss adding ptr to a long that should h...   Oct 18 2019, 03:10 PM
||||- - Knuckles   Thanks Colin. I guess I won't really know unt...   Oct 18 2019, 03:15 PM
||||- - isladogs   It would obviously help to have at least 1 user on...   Oct 18 2019, 03:23 PM
||||- - Knuckles   The databases are all .accdb. I don't think th...   Oct 18 2019, 03:29 PM
||||- - AlbertKallal   Sounds like you are on your way. Just as a FYI? I...   Oct 18 2019, 06:30 PM
||||- - Knuckles   Greetings all and happy Monday, We have been test...   Oct 21 2019, 11:39 AM
||||- - isladogs   I believe the error occurs when the object already...   Oct 21 2019, 01:09 PM
||||- - cheekybuddha   Either that, or the SAPLogonControl is not registe...   Oct 21 2019, 01:13 PM
||||- - tina t   PMFJI, guys, but i'm wondering about the follo...   Oct 21 2019, 01:16 PM
||||- - cheekybuddha   Yes, Tina, you are correct.   Oct 21 2019, 01:17 PM
||||- - isladogs   Tina You are correct. Each variable needs to be de...   Oct 21 2019, 01:19 PM
||||- - Knuckles   It is registered, we are thinking it is that SAP i...   Oct 21 2019, 01:31 PM
|||||- - isladogs   It may well be so, but I doubt that would cause er...   Oct 21 2019, 01:54 PM
||||- - tina t   thanks, Colin and David. :) tina   Oct 21 2019, 04:28 PM
||||- - Knuckles   Thank you all, we are digging into SAP a bit. Knu...   Oct 21 2019, 05:04 PM
|||- - BruceM   Ah, these language barriers.   Oct 18 2019, 12:29 PM
||- - tina t   hey, Colin, when i click your posted link for Wind...   Oct 17 2019, 04:12 PM
||- - isladogs   Hmm...that was the link given in the utility!...   Oct 17 2019, 04:22 PM
||- - tina t   you're welcome, Colin, and thanks for the good...   Oct 17 2019, 07:58 PM
|- - Knuckles   Declare PtrSafe Function SetWindowPos Lib "us...   Oct 17 2019, 11:22 AM
- - PhilS   QUOTE I got an error that came up in a loop ...   Oct 17 2019, 01:56 PM
- - Knuckles   Thank you Phil. We did think they were separate i...   Oct 17 2019, 02:04 PM



Custom Search


RSSSearch   Top   Lo-Fi    11th December 2019 - 10:49 PM