Code Is Loosing Value

crhodus

Registered User.
Local time
Today, 08:36
Joined
Mar 16, 2001
Messages
257
Can anyone help me? I'm not too familiar with VB, plus it's been a while since I wrote this code.

I believe that the strInput_User_Name is loosing its value as the user uses the program throughout the day. The InputBox launches whenever the database is opened. If the user does not enter his/her name, then the switchboard form is closed. The value in strInput_User_Name is recorded in different fields throughout my database whenever data is added or modified on a form.


Public Function Input_User_Name()

Dim MsgResult
DoCmd.RunMacro "mcrMAXIMIZE"
MsgResult = vbNo
Input_User_Name = InputBox("Please enter your name.", "EIB Contact Management System")

If Input_User_Name = "" Then
Do Until Input_User_Name <> ""
Input_User_Name = InputBox("You MUST enter your name before continuing. Please enter your name.", "EIB Contact Management System")
If Input_User_Name = "" Then
MsgResult = MsgBox("Quit EIB System?", vbYesNo + vbQuestion)
If MsgResult = vbYes Then
strCloseSwitchboard = "1"
DoCmd.Close acForm, "Switchboard"
Exit Do
End If
End If
Loop
Else: strInput_User_Name = Input_User_Name
'above line added 5/14/01
End If

'strInput_User_Name = Input_User_Name
'This should be done outside of the function since Input_User_Name itself caries the value - this line is redudant here

End Function

According to the code that has been written, will strInput_User_Name always store some value, except for null?

Someone here on the forum helped me with writing this code. There is a comment saying that "strInput_User_Name = Input_User_Name should be done outside the function"? Is this true?

Please let me know if I need to clarify.

Thanks!

[This message has been edited by crhodus (edited 08-24-2001).]
 
Hi chrodus,

don't know if u still need this as u posted a while ago but, anyway. The value will be lost if you get any code errors and someone hits 'end', i guess it may also be lost due to flakey M$-ness. You may have more luck with a hidden form with a UserName field on it, that should survive non-critical errors without any problem,

HTH

Drew
 
Thanks Drew. I took a 2 day Access class this week and saw something similar to this being done in the class. I was thinking about doing this while sitting in class, but I wasn't sure if I should or not. Guess you saved me from having to ask the forum. Thanks again!
 

Users who are viewing this thread

Back
Top Bottom