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
> 64 Vs 32 Bit Error, Any Version    
 
   
mrcunknown
post Nov 5 2018, 05:25 PM
Post#1



Posts: 17
Joined: 22-September 18



Hi,

I'm making use of a login system that works on the username and password of the WINDOWS system. On a 64 bit the login works, but on a MS 32 bit system is dont work. Is there somebody who can help me? iconfused.gif
Attached File(s)
Attached File  login_system___kopie.zip ( 294.95K )Number of downloads: 5
 
Go to the top of the page
 
theDBguy
post Nov 5 2018, 05:28 PM
Post#2


Access Wiki and Forums Moderator
Posts: 73,749
Joined: 19-June 07
From: SunnySandyEggo


Hi,

You're probably using an API to get the username. You might like to try this non-API approach to see if it will work for you.

Just a thought...

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
mrcunknown
post Nov 6 2018, 06:02 AM
Post#3



Posts: 17
Joined: 22-September 18



thnx for your reply. At this moment i get the following popup (see pic). I dont know how to use youre code. Where do i put it?
Attached File(s)
Attached File  Capture1.JPG ( 22.42K )Number of downloads: 3
 
Go to the top of the page
 
theDBguy
post Nov 6 2018, 11:02 AM
Post#4


Access Wiki and Forums Moderator
Posts: 73,749
Joined: 19-June 07
From: SunnySandyEggo


Hi,

Try copying the code from my website into a Standard module called "modUser." Then, wherever you need to get the username, just use modUser.Username

Let us know how it goes...

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
mrcunknown
post Nov 11 2018, 03:57 AM
Post#5



Posts: 17
Joined: 22-September 18



Hi theDBguy,

I have tryed to do that ... but it does not work (maybe i did something wrong iconfused.gif ).
Go to the top of the page
 
theDBguy
post Nov 11 2018, 10:32 AM
Post#6


Access Wiki and Forums Moderator
Posts: 73,749
Joined: 19-June 07
From: SunnySandyEggo


Hi,

Can you show us what you did? Or better yet, can you post a sample copy of your db?

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
mrcunknown
post Nov 12 2018, 02:41 AM
Post#7



Posts: 17
Joined: 22-September 18



ok .... this is what i did. I hope you can help me with it.
Attached File(s)
Attached File  login_system___2.zip ( 298.61K )Number of downloads: 1
 
Go to the top of the page
 
theDBguy
post Nov 12 2018, 03:10 PM
Post#8


Access Wiki and Forums Moderator
Posts: 73,749
Joined: 19-June 07
From: SunnySandyEggo


Hi,

Hope this helps...

Attached File(s)
Attached File  login_system.zip ( 295.22K )Number of downloads: 3
 

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
mrcunknown
post Nov 13 2018, 01:41 AM
Post#9



Posts: 17
Joined: 22-September 18



Nope .... i get a other error.
Attached File(s)
Attached File  Capture.JPG ( 87.92K )Number of downloads: 6
Attached File  Capture1.JPG ( 26.46K )Number of downloads: 3
 
Go to the top of the page
 
PhilS
post Nov 13 2018, 03:28 AM
Post#10



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


Regarding the original API approach:
The error messages says, it can't find the DLL entry point GetWindowLongA.
I'm not sure why you would need this API function in the context of getting the Windows user name.

...


I noticed, you uploaded your database and I had a look...
There are two critical issues you need to fix before you do anything else.

- The name for the project is "Database". - This conflicts with the DAO.Database class and should be changed. (Menu: "Tools"-"Database Properties"-"Project Name").

- The type tagOPENFILENAME is declared two times in the project. Some procedures use one of the declaration and then pass it to APIs that use the other declaration. - You need to get rid of the duplicate declaration of tagOPENFILENAME.

These two issue might cause all sorts of weird behaviour.

General advice: Compile your code frequently. (Menu: "Debug"-"Compile ...")) - If it does not compile, there is a problem that needs to be addressed!

--------------------
Go to the top of the page
 
DanielPineault
post Nov 13 2018, 06:06 AM
Post#11


UtterAccess VIP
Posts: 6,220
Joined: 30-June 11



First off, your code doesn't compile without errors, so you need to regularily compile and address all the errors flagged by the compiler.

Secondly, when creating a database to run on both 32 and 64 bit systems, you need to use Conditional Compilation Directives so you have APIs declared properly for each bitness. For instance, for the fOSUserName function, you'd need to declare the API like:

CODE
#If VBA7 And Win64 Then     'x64 Declarations     Private Declare PtrSafe Function apiGetUserName Lib "advapi32.dll" Alias _             "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long #Else     'x32 Declaration     Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _             "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long #End If


You'll need to do similarily for all your API declarations.




You may also like to review http://www.devhut.net/2017/04/13/access-x3...-compatibility/


I'd also recommend you check your database for Reserved Words, see: https://www.devhut.net/2017/06/21/ms-access...d-word-checker/ for instance, tblLogins, your field named Usera and Name are both no-nos.



Sorry about the formatting, but the UA editor is buggy. It was originally all well formatted. Use the link provided to see the code properly formatted.


--------------------
Daniel Pineault (2010-2018 Microsoft MVP)
Professional Help: http://www.cardaconsultants.com
Free MS Access Code, Tips, Tricks and Samples: http://www.devhut.net

* Design should never say "Look at me". It should always say "Look at this". -- David Craib
* A user interface is like a joke, if you have to explain it, it's not that good! -- Martin LeBlanc


All code samples, demonstration databases, links,... are provided 'AS IS' and are to be used at your own risk! Take the necessary steps to check, validate ...(you are responsible for your choices and actions)
Go to the top of the page
 
isladogs
post Nov 13 2018, 08:37 AM
Post#12



Posts: 648
Joined: 4-June 18
From: Somerset, UK


Daniel

As I was recently reminded myself by BruceM at this forum, the code you supplied is I believe more complex than necessary.

The #If VBA7 section with PtrSafe (& LongPtr where needed) will work in Access 2010 or later whether 32-bit or 64-bit
The Win64 part is unnecessary UNLESS you have APIs like GetTickCount/GetTickCount64 that only work in specific bitness
If some users are running 2007 or earlier you also need the #Else section (to cover VBA6 32-bit) otherwise it can be omitted

So one of these is all you need
a) All users running 2010 or later (i.e. VBA7) 'no conditional compilation needed - include LongPtr for pointers such as hWnd
CODE
Private Declare PtrSafe Function apiGetUserName Lib "advapi32.dll" Alias _
                 "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long


b) Some users also running 2007 or earlier
CODE
#If VBA7 Then    'include LongPtr for pointers such as hWnd
    Private Declare PtrSafe Function apiGetUserName Lib "advapi32.dll" Alias _
               "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
#Else    
     Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _            
     "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
#End If

This post has been edited by isladogs: Nov 13 2018, 08:38 AM
Go to the top of the page
 
theDBguy
post Nov 13 2018, 01:00 PM
Post#13


Access Wiki and Forums Moderator
Posts: 73,749
Joined: 19-June 07
From: SunnySandyEggo


Re: "Nope .... i get a other error."

Not sure why you got an error but I just downloaded the attachment and tried it again without any errors. As others said, try to compile your project first and fix any errors to make sure there are no conflicts between your variables and objects.

Good luck!

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    18th November 2018 - 04:30 PM