Results 1 to 4 of 4
  1. #1
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    austin, Texas, USA
    Posts
    1,029
    Thanks
    0
    Thanked 0 Times in 0 Posts
    working on this at the moment, thought i'd swing by the lounge...

    in the Login form, there's this:

    Code:
    Option Compare Database
    Public globalUserID As String
    Public globalClassification As String
    Option Explicit
    the var gets loaded here:

    Code:
    		
    Public Sub cmd_OK_Click()
    ... logic to confirm/deny login...
    globalUserID = rsLogin("USER_ID").Value
    		globalClassification = rsLogin("Classification").Value
    		DoCmd.Close acForm, "Login"
    		'DoCmd.OpenForm "Background"
    		DoCmd.OpenForm "RUG"
    End Sub
    As you can see, the login form is closed and control is passed to the form RUG. in "On Load" I try this:

    Code:
    Dim globalUserID As String
    MsgBox "Welcome, " & globalUserID
    Do i need to call the public function from the Login? I tried that and it says "Sub or Function Not Defined".

    All I want to do is capture the logged in user's ID in memory and, once the edits are processed and finalized by the user, write that value to the underlying table(s) that handle the edits.

    TIA

  2. #2
    5 Star Lounger AndrewKKWalker's Avatar
    Join Date
    Apr 2001
    Location
    Cambridge, UK
    Posts
    1,020
    Thanks
    0
    Thanked 3 Times in 3 Posts
    [quote name='steve_skelton13' post='798812' date='19-Oct-2009 17:08']working on this at the moment, thought i'd swing by the lounge...

    in the Login form, there's this:

    Code:
    Option Compare Database
    Public globalUserID As String
    Public globalClassification As String
    Option Explicit
    the var gets loaded here:

    Code:
    		
    Public Sub cmd_OK_Click()
    ... logic to confirm/deny login...
    globalUserID = rsLogin("USER_ID").Value
    		globalClassification = rsLogin("Classification").Value
    		DoCmd.Close acForm, "Login"
    		'DoCmd.OpenForm "Background"
    		DoCmd.OpenForm "RUG"
    End Sub
    As you can see, the login form is closed and control is passed to the form RUG. in "On Load" I try this:

    Code:
    Dim globalUserID As String
    MsgBox "Welcome, " & globalUserID
    Do i need to call the public function from the Login? I tried that and it says "Sub or Function Not Defined".

    All I want to do is capture the logged in user's ID in memory and, once the edits are processed and finalized by the user, write that value to the underlying table(s) that handle the edits.

    TIA[/quote]


    I could be wrong, but I think that Public variables and Constants cannot be declared in a Forms Private Module and then referenced after the form is closed.

    You would need to define the Public variables in a Module and then write data to them from within the form.
    Then once the form is closed hey will still be in scope
    Andrew

  3. #3
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts
    Andrew is correct - you want to define the Global value in a module, but you don't want to define it again in another module. The bigger question is instead of reinventing the wheel by devising your own login process, why not either capture the Windows login, or activate Access User Security and use that login? There are a number of threads on both techniques in the Lounge.
    Wendell

  4. #4
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    austin, Texas, USA
    Posts
    1,029
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I was thinking I had to move the code to a regular module. will do that.

    Wendell, as to your suggestion to do something more interesting like capture the network userid or something along those lines, i originally thought that would be a better option, but the access project i am building will be used off-line, as it were, so I don't think the network login data would be available. Anyway, there's already a pre-defined table for id's, passwords and roles so I opted to use that instead. I don't like working with Access roles and securities, always found that to be a bit too confusing. I *am* blonde, you know.

Posting Permissions

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