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

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
3 Pages V  1 2 3 >  (Go to first unread post)
   Reply to this topicStart new topic
> Removing Ptrsafe, Access 2016    
 
   
Knuckles
post Oct 17 2019, 10:25 AM
Post#1



Posts: 901
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
 
nuclear_nick
post Oct 17 2019, 10:44 AM
Post#2



Posts: 1,798
Joined: 5-February 06
From: Ohio, USA


Allow me to help you clarify your post...

1) O365 is a subscription service, not an Office version.
2) O365 does not automatically mean the subscriber has 64 bit Office.

Finally, a question of my own... have you looked into ALL the possibilities behind the message "Cannot open any more databases"? I don't offhand know of any that would be caused by ptrsafe, but perhaps someone else will come along and help with that part... tongue.gif

--------------------
"Nuclear" Nick
____________
The top three reasons to hide code; 1) It's not your own. 2) It's your own, but it's so crappy you don't want anyone to see it. 3) The comments in your code would get you in a lot of trouble if ever made public.
Go to the top of the page
 
arnelgp
post Oct 17 2019, 10:48 AM
Post#3



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
 
isladogs
post Oct 17 2019, 10:55 AM
Post#4


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


To add to Nick and arnel's comments, the way to deal with mixed 32/64-bit versions of Office is using conditional compilation.

The cannot open any more databases error is usually seen when Access has a lot of objects open at once e.g. Tables, forms, reports, recordsets.
Each open object uses up some of the 255 connections theoretically available.
For that reason it is a good idea to close objects not currently in use
You may find this utility useful Check Available Connections

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



Posts: 901
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#6


UtterAccess VIP
Posts: 1,808
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
 
Knuckles
post Oct 17 2019, 11:10 AM
Post#7



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



Thanks Colin, I will check out the available connections and will try the debug.print
Go to the top of the page
 
arnelgp
post Oct 17 2019, 11:11 AM
Post#8



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#9



Posts: 901
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
 
isladogs
post Oct 17 2019, 11:22 AM
Post#10


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


There should only be one # on the If line
#If VBA7 Then

#Else

#End if

Just copy the exact code arnel has given you.

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



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:22 AM
Post#12



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



Declare PtrSafe Function SetWindowPos Lib "user32" (ByVal hwnd As LongPtr should this be"user32" or 64?
Go to the top of the page
 
Knuckles
post Oct 17 2019, 11:23 AM
Post#13



Posts: 901
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#14



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#15



Posts: 901
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#16


UtterAccess VIP
Posts: 1,808
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#17



Posts: 901
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
 
PhilS
post Oct 17 2019, 01:56 PM
Post#18



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


QUOTE
I got an error that came up in a loop "Cannot open any more databases"

QUOTE
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.

DSomething and Recordset related code may very well cause an "Cannot open any more databases"-error. - PtrSafe may not, because it has no effect past compilation.
You're barking up the wrong tree.

--------------------
Go to the top of the page
 
Knuckles
post Oct 17 2019, 02:04 PM
Post#19



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



Thank you Phil. We did think they were separate issues.
Go to the top of the page
 
isladogs
post Oct 17 2019, 02:14 PM
Post#20


UtterAccess VIP
Posts: 1,808
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
 
3 Pages V  1 2 3 >


Custom Search


RSSSearch   Top   Lo-Fi    17th November 2019 - 01:22 PM