Results 1 to 5 of 5
  1. #1
    Join Date
    Nov 2002
    Location
    Oakland, CA
    Posts
    126

    Unanswered: Global Variable from login

    Can somebody please help me to post the code for storing a variable from a form to use it later in reports, etc.

    I have a db setup so it has a login that let's the user through, I would like to capture that string of user name and use it later. Right now I make the form visible = false and then use the information of the text field in other reports. There must be a way through VB. Anybody has any idea? I would like to see the code for the click button as well as for the module function. Thanks

  2. #2
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    in a global module:
    global MyVar as string


    in the module of a form containing MyButton and MyTextBox:
    private sub MyButton_Click()
    MyVar = MyTextBox.Value
    end sub



    izy

  3. #3
    Join Date
    Nov 2002
    Location
    Oakland, CA
    Posts
    126
    Ok, this was way too easy, I was trying to pass the variable and obviously it didn't work . Thanks Izy


    Originally posted by izyrider
    in a global module:
    global MyVar as string


    in the module of a form containing MyButton and MyTextBox:
    private sub MyButton_Click()
    MyVar = MyTextBox.Value
    end sub



    izy

  4. #4
    Join Date
    Nov 2002
    Location
    Oakland, CA
    Posts
    126
    One more thing, how would I display that variable on a report??? Thanks

  5. #5
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    don't know, but here are two guesses:

    1. the query-cheat
    write a (global, or will report-level work?) function that returns the value of MyVar and use the function in the report.

    2. report level code
    Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    thisBox.Value = MyVar
    End Sub

    izy

Posting Permissions

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