Unanswered: setting the caption one one form from another.
i have a login system for the help desk application im building at the moment, and im stuck on this point:
once the user inputs their user name and password, they click on the login button.
from there, assuming the password is accepted, the value of the combo box (called username) is then populates a variable called user_log_id i.e. if the user login name is bloggsj then that should be the value stored in the variable.
now what i want to do is to set a label fields caption to the value of that variable.
i have used the following (rough) code after the login is successful:
DIM user_log_id As String
Set user_log_id = Me!login_select.Value
DoCmd.open form "main"
**set label 139's caption to the variable user_log_id here**
The above code is just a rough outline of what i am trying to do, but it has me really stumped.
All you need to do is create a new module in access, and in the module define your variable as a global one. You will need to remove the Dim from your forms code in order for this to work. Code for module:
Global user_log_id As String
Set user_log_id to equal the user name they chose, then in the On Load function of "Main", just add the code:
Me.YourLable.Caption = user_log_id
That should work just fine for you. I had something similar to this in a project I was working on earlier this week.
What you can do is put some global variables in to store some values in,
Before you open the 2nd form store all the variables in the form exit or button click event etc. and then call the variables from the form_activate event
something like this
Public myTest As String, strFormName As String
Public bolTest As Boolean
form leaving event
Private Sub Command14_Click()
bolTest = True
myTest = Me!lblStaffGrade.Caption
strFormName = Me.Name
and your opened forms activate event
Private Sub Form_Activate()
If bolTest = True Then
Label60.Caption = myTest
DoCmd.Close acForm, strFormName