Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2004

    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 form "main"
    **set label 139's caption to the variable user_log_id here**
    DoCmd.CloseForm Me
    The above code is just a rough outline of what i am trying to do, but it has me really stumped.

    If anyone could help, i'll really appreciate it.


  2. #2
    Join Date
    Dec 2004
    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.

    Last edited by unheard; 12-17-04 at 11:25.

  3. #3
    Join Date
    Jan 2004
    Aberdeen, Scotland
    Hi cruickshanks

    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

    variable decleration
    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
        DoCmd.OpenForm "frmGroup"
    End Sub
    and your opened forms activate event

    Private Sub Form_Activate()
        If bolTest = True Then
            Label60.Caption = myTest
            DoCmd.Close acForm, strFormName
        End If
    End Sub

    p.s. no extra babies yet

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts