I haven't used VBA in access for a minute here, but now I am back in it and trying to use this wonderful function in access 2016 but I get this error. What do I need to change so I can use this function?
https://ibb.co/hLK80YG
I haven't used VBA in access for a minute here, but now I am back in it and trying to use this wonderful function in access 2016 but I get this error. What do I need to change so I can use this function?
https://ibb.co/hLK80YG
Last edited by jo15765; 01-19-2020 at 05:48 PM. Reason: embedded image
Try:
Private Declare PtrSafe Function ...
Or
Don't use API function and instead use Environ("USERNAME").
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
See this link fort 3 different methods of getting user name http://www.mendipdatasystems.co.uk/g...ame/4594424315.
If you really want to use the API, the link includes the code to convert it to 64-bit.
However I would recommend using either Environ("UserName") or CreateObject("WScript,Network").UserName instead
Thanks, I'll adapt it to use on a 64x system.
I'm steering away form Environ("UserName") as this db will be accessed on a few OSX systems and I've read stories of it not working on OSX.
I know a guy who was better at this than me, who always used Environ in his db's in a corporate environment where anybody who had Access had the same version. Db's were always properly split and distributed, there were no RunTime versions involved etc. etc. and one day, it just stopped working. He switched over to fosUserName, which fortunately I was already using. I've read about Environ properties getting dropped at times so between that and the other guy's experience, I saw no need to switch. Most of my user properties came from a user class anyway, which means that once the function set the property I didn't need to call it again for anyone's session. I know I'm going to get a bit of blow back on the Environ thing...I've read stories of it not working on OSX.
The more we hear silence, the more we begin to think about our value in this universe.
Paraphrase of Professor Brian Cox.
All methods work but personally I see no benefit in using an API for this. It just adds complexity for no reason.
I'm not sure what relevance OS X has to this as Access doesn't run on an Apple OS.
Or did you mean Windows 10? If so you've heard wrongly.
My only concern with using Environ is that the output can be 'spoofed' if you know how.
Using WScript is just as easy and cannot be 'spoofed' so that's my method of choice in a multi user environment.
However, all methods work so each to their own ....