Results 1 to 3 of 3
  1. #1
    injanib is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jan 2011
    Posts
    67

    Passing data between forms


    Hello,

    On my database I have a login system. The login system restricts the number of failed attempts, locks account, expires password and encrypts the password with MD5 encryption before writing them in the table. I pass the username between forms in order to restrict certain controls on each form based on the users' access level. The way I have it right now is that upon the user's successful login, a form is opened invisibly and the username is passed on to an unbound control on this form. The appropriate event of each control that I want to restrict, runs a DLookup for the access level of the username in the unbound field of the invisible form and then proceeds accordingly. The code is similar to the following:

    If DLookup("AccessLevel","tblUsers","[Username]=' " & Forms!frmInvisible.txtUnboundField & " ' ")= ... then ...

    This works great most of the time, however I have experienced that occasionally this will not work at all. The event of some of the controls will not do anything at all as if there were no code behind them, which I think might be because the unbound field on the invisible form is blank. And some controls give a message saying the referenced form was not found, as if the form never opened or got closed.

    I am certain that the form is not closed by any other event except the on timer event of the invisible form itself, which closes all the opened forms if a 15 minute idle time is detected and puts the users behind the login screen. But, the login form re-opens the form and pass on the username to it when the login is successful.

    I wonder why this method does not always work, and if there is a more reliable and effective method to do this. Is it possible to have a function holding the username and can be checked by events of my controls? If yes, how can I do it.

    Thanks in advance.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,616
    You can have a global variable hold the username then anything can reference the value anywhere. Be aware that global variable can be an issue when debugging because whenever code execution is interrupted, variables are reset.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    injanib is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jan 2011
    Posts
    67
    Oh that is an excellent idea. I didn't know how to do this, and although I have not really tried how it works with this particular issue, but I know I can do allot more with this.

    Thank you, thank you for this neat idea.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. passing values between forms
    By paulw in forum Access
    Replies: 4
    Last Post: 06-15-2011, 08:52 AM
  2. Passing Data Between Forms
    By exeTrix in forum Programming
    Replies: 3
    Last Post: 04-05-2011, 01:06 PM
  3. Passing Data from on Form to Another..
    By ETCallHome in forum Forms
    Replies: 2
    Last Post: 03-12-2011, 12:26 AM
  4. PASSING Values between Forms
    By chhinckley in forum Programming
    Replies: 1
    Last Post: 08-27-2010, 10:19 AM
  5. Replies: 3
    Last Post: 06-02-2009, 09:51 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums