Storing Values

CBragg

VB Dummy
Local time
Today, 17:54
Joined
Oct 21, 2002
Messages
89
Im wondering how to store a value on one form so i am able to use that value on other forms.

i.e. someone logs on using a custom form and then on the main data input screen it displays who's logged on.

Any ideas would be greatly appreciated.

Thanks in advance.
 
Easiest thing to do is open a hidden form at startup with a textbox that contains the user's name.

When you want to refer to it, simply put in the ControlSource of other textboxes:

=Forms!MyForm!MyTextbox

Where MyForm is the name of the hidden form and MyTextBox is the name of the hidden form's textbox.
 
Thanks, but ive already done that on the previous version, it was rather messy.

I believe that the more efficient way would be to store the value.

Any ideas on that?
 
What about a table of users who can use the database?

tblUsers
UserID
Forename
Surname
LoginID
etc.


Put this in a module:

Code:
Public Function GetFullUser() As String
    On Error Goto Err_GetFullUser
    Dim strFore As String
    Dim strLast As String
    strFore = DLookup("Forename", "tblUsers", "LoginID = """ & Environ("username") & """")
    strLast = DLookup("Surname", "tblUsers", "LoginID = """ & Environ("username") & """")
    GetFullUser = strFore & " " & strLast
Exit_GetFullUser:
    strFore = vbNullString
    strLast = vbNullString
    End Function
Err_GetFullUser:
    GetFullUser = vbNullString
    Resume Exit_GetFullUser
End Function

And then, in the controlSource of any textbox you want (or in VBA) you can simply put =GetFullUser()
 
Unfortunatly when the user enters data this value is put into the database so we know who entered what, the way you explain it wont work because if you scroll through the data it will change to whoever logs in regardless of whether they've entered data or not.

No idea's on storing values?? Is it in global declarations??

Thanks for your help so far though.
 

Users who are viewing this thread

Back
Top Bottom