Chr(0) throws and error

DanielR

Registered User.
Local time
Today, 09:11
Joined
Mar 16, 2018
Messages
72
When I deploy my access application and I run it I get an error at this line:
GetLogonName = Left(lpBuff, InStr(lpBuff, Chr(0)) - 1)
It seems to have an issue with Chr(0).
Can you help please?
 
What does chr(0) mean to you? -that is what is your intent with -
Code:
[COLOR="DarkOrchid"]GetLogonName = Left(lpBuff, InStr(lpBuff, Chr(0)) - 1)[/COLOR]

Are you reading some file? If so could you tell us about the data in that file?
 
Chr(0) returns the Null character. I expect the code is looking to remove the last character from a Null terminated string if it is present.

The expression will throw an error is there is no Null in the string because Instr would return zero passing a -1 to Left().

When searching for an optionally present character, always concatenate the search character onto the end of the string to avoid errors if it isn't already present.

Code:
GetLogonName = Left(lpBuff & Chr(0), InStr(lpBuff & Chr(0), Chr(0)) - 1)
 
To be pedantically correct, Galaxiom, Chr(0) returns the NUL character, using the US-ASCII name for that particular bit pattern. We might colloquially call it Null, but it really isn't Null, it is NUL.

If Chr(0) actually returned a Null, then you would probably get "Invalid use of null" as an error. Speaking of which, ...

DanielR - you say you get an error and you told us where. But you didn't identify WHICH error you get. Please advise us.
 
The error came up when I deployed the access app to another machine using SSE Setup -> exe file install, etc.
I also got a missing: Microsoft office 15.0 object library
This might be causing the chr(0) error.

I have split the database into front end and back end.
I wound up creating a shortcut to the front end and coping that onto users machine and it works fine. No Chr(0) errors.
 
I installed Microsoft runtime for access2013...I developed the app in access 2013. They should have been in line with each other. How do you perform late binding? Would that just be going into the reference section of the app and binding?
 
The user has office 2013 installed.

No worries...I just copied a shortcut of the accdb file to the users desktop.
Works fine.

Thank you for the help.
 

Users who are viewing this thread

Back
Top Bottom