I am an OfficeXP Win2000 developer and am experiencing a problem after
a public variable is set.
Public variables involved:
Public strRole As String
Public strLoggedUser As String
Public strLab As String
When a user successfully logs into the database public variables are
set including their name, role, and lab. I use the name
(strLoggedUser) and lab (strLab) on a form named frmAssay (bound to a
table). When this form opens, the user is prompted to select either
'Tube' or 'Plate' assay type. The after update event for this option
button control sets the value for the [Assayer] field to that of the
public variable strLoggedUser: Me.Assayer.Value = strLoggedUser.
This all seems pretty straight forward, except it does not always
work.
Login Click CODE that sets variables:
strLoggedUser = DLookup("User", "tlkUsers", "[User]
Forms![frmLogIn]!Userid")
strLab = DLookup("Lab", "tlkUsers", "[User]
Forms![frmLogIn]!Userid")
After Update CODE:
Me.Assayer.Value = strLoggedUser
Me.Lab.Value = strLab
The problem: Sometimes the strLoggedUser variable changes to nothing.
Checks made when this happen (using the immediate window):
?IsEmpty(strLoggedUser) returns False, which means it's initialized.
?IsNull(strLoggedUser) returns False, which means it contains
characters. ?strLoggedUser returns a blank, which is confusing
considering what the IsEmpty and IsNull is returning.
The problem occurs every time I am stepping through the code.
Nothing in the code is resetting strLoggedUser to any other value.
Thanks for looking,
Bob