Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

form don´t update a public variable data

Status
Not open for further replies.

Albano

Instructor
Dec 11, 2000
221
PT
Hi,

I have a form to make the login on the app, the username is stored in a public variable.
Logging on the app whill send the user to a menu form, but when I retrive the value on that form, on the first time the value is the nothing or the last user that logged on.
I thik theire is a delay, someane can help.

Thanks,

Albano
 
Where is this Public variable declared?

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
Hi, I declare the public variable on a module. I use the onload event to retrive the value of the variable when the form is loaded, could be a problem of that event?
 
Don't have a clue. Tried the exact same thing you've described and it works without a problem. Could we see the code where you assign a value to the variable and also the code for retrieving it? I'm also confused as to how the variable can be empty sometimes and have the last user's name sometimes. The variable being blank is how it should be when the db first opens, until a value is assigned. The only way the last user's name should show up is if you are changing users without exiting the db.

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
ok, their's the code
Code for variable declare in a module:

Option Compare Database
Option Explicit

Public userName As String - >user name variable
Public tipoUser As Integer ->Group where user bellong

Code where the variable is retrieve:

Private Sub Form_Load()
MsgBox getAcessos(tipoUser, "Consultor - Dados Pessoais")
userLogado.Value = userName

End Sub

The same hapens when I call the function getAcessos() the value don´t get retreaved the first time I open the form.
The function is in the same module.
 
Where is the code for loading the variable and what does getAcessos do?

Try reversing your code:

Code:
Private Sub Form_Load()
    userLogado.Value = userName 
    MsgBox getAcessos(tipoUser, "Consultor - Dados Pessoais")
End Sub

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
Thanks for every thing, but I already seen what whas the problem, I set the variable value in the wrong place, and the value whare lost betwenn forms

Thanks.

Albano
 
Glad you got it fixed!

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top