Results 1 to 14 of 14
  1. #1
    stoey is offline Novice
    Windows XP Access 2003
    Join Date
    Mar 2011
    Posts
    7

    Display user's database or record after login

    Hi there,

    Anybody knows how can I display the user's record after he/she logged in? I have a username and password form...this works perfectly but i dont know how to incorporate this such that after the user logged in, it will display his data allowing him to do some modifications like editing and saving a record. Any help is deeply appreciated.

    Thanks,



    stoey

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    After the person is logged in you have to save the primary key for that person so you can reference it. What I've done in the past is just pass the unique key of my users table to the next form after the login screen. Let's say your login screen is called frmLogin. Your login information is on tblLogins (LoginID, LoginUser, LoginPW). And after your user logs in you want to open form frmMainSwitchboard.

    On frmMainSwitchboard have an unbound field that is called ID (or something similar) and make the visible property NO or FALSE.

    When you move from frmLogin to frmMainSwitchboard you'd just need a line of code something like:

    open frmmainswitchboard
    forms!frmMainSwitchboard!ID = dlookup("[LoginID]", "tblLogins", "[LoginUser] = '" & forms!frmLogin!username & "'")
    close frmLogin

    I may have missed some punctuation on the dlookup but you get the idea. Then whenever you need to check a permission for that person you check it against their ID.

  3. #3
    stoey is offline Novice
    Windows XP Access 2003
    Join Date
    Mar 2011
    Posts
    7
    hi rpeare,

    thanks for the quick reply...if it is not too much to ask, can you provide me a working sample database which displays the user's record after login? I tried your suggestion and I don't see, to get it to work...dumb me...I hope you can provide me something to get start with...Thanks a lot in advance.

    stoey

  4. #4
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    Simple example

  5. #5
    stoey is offline Novice
    Windows XP Access 2003
    Join Date
    Mar 2011
    Posts
    7
    hello rpeare,

    i would like to thank you first and foremost for the sample file you shared...thank you very much! i tried the file and incorporate some sample data on it but my problem is, it doesn't display the proper data once the user logged in....i tried merging the tables but i guess i am not doing it the right way...sorry im very new to this...attached is the sample...

    regards,

    stoey

  6. #6
    IdleJack is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2011
    Location
    Leeds, West Yorkshire England
    Posts
    15
    sorry to jump in on this thread but I have a question.

    Is it possible to use the input mask 'password' on various forms so that only individuals with user names/passwords associated with the table/form are able to access them?

  7. #7
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    You are going to encounter problems with the way you have things set up because your two tables to not share any parent/child relationship, they both have a unique key (autonumber) but they are independent of one another.

    So you have a couple of options.

    1. Put all your data in one table. It looks like you intend to have a one to one relationship between your two tables so there's no real reason to split them up.

    2. Do your data entry in such a way that your table tblData carries the foreign key of your tblUsers table so that you have some established link between the two.

  8. #8
    stoey is offline Novice
    Windows XP Access 2003
    Join Date
    Mar 2011
    Posts
    7
    hi rpeare,

    tnx again for replying...uhm...sorry but i don't understand what you mean about that...im new to programming access...all i know is how to use the wizard...hehehe...so im trying to learn here...anyway...would it be fine if I just use 1 table for all both data and table users? would there be a problem if I only use one table? like if I only use one table then it will most likely contains 100 records of data?

    regards,

    stoey

  9. #9
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    You're mixing terminology so I'm not entirely sure what you're asking. a RECORD is a single line in a single table or query. a FIELD is a single piece of data within a RECORD. If you are saying you have 100 FIELDS (pieces of data) you have to keep track of for each employee then yes you can do this on a single table. However, you have to look at normalizing your table. If there are pieces of information that repeat (let's say a person can have multiple phone number contacts) you would want to keep that in a sub table that was strictly for phone numbers. I don't know what your data structure is, I'm just saying what it looked like to me based on what you posted.

  10. #10
    stoey is offline Novice
    Windows XP Access 2003
    Join Date
    Mar 2011
    Posts
    7
    hi rpeare,

    my apologies for confusing you...i attached the sample file you shared to me and i included some example record. curently there are 2 record samples...the problem is, still it wont display the proper data after login...if I entered login for user 000001, it should display the name and address of Anderson, Neo...if i entered the login for user 000002, it should display the name and address of Sparrow, Jack....but when I run the program, it logs in after inputting the proper username and password yet it wont work

    regards,

    stoey

  11. #11
    TinaCa is offline Advanced Beginner
    Windows Vista Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    87
    If I can add two sense. Maybe a Public Sub with a global variable. The variable would be set when the user logins in. i.e. loginId = textbox on form. Then call the Public Sub whenever a form is opened to grab the global variable loginId. You can then use code on the form to determine the users rights to the form.

  12. #12
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    In the ON CLICK event of the LOG IN button put in a row directly after this line:

    DoCmd.Close acForm, "frmLogin"

    type in

    Forms!frmmainswitchboard.Requery

    On the frmMainSwitchboard change the RECORD SOURCE from

    tblUsers

    to

    Code:
    SELECT tblUsers.UserID, tblUsers.UserName, tblUsers.PassWord, tblUsers.Name, tblUsers.Address FROM tblUsers WHERE (((tblUsers.UserID)=[forms]![frmmainswitchboard]![fldLoginID]));

  13. #13
    TinaCa is offline Advanced Beginner
    Windows Vista Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    87
    rpeare, would this require that the switchboard for always be open? Also, would he have to requery the form on each new form that the user opened?

  14. #14
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    His original request was to only modify the record of the person that was logged in he hasn't mentioned any other need so that's the example I gave. I am not saying your method isn't equally valid, lord knows there are half a dozen ways to do everything with Access.

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

Similar Threads

  1. Replies: 7
    Last Post: 06-24-2011, 10:42 PM
  2. Replies: 0
    Last Post: 07-07-2010, 12:57 PM
  3. Login and user levels
    By seanog2001 in forum Forms
    Replies: 0
    Last Post: 10-27-2009, 05:13 AM
  4. Database Login Issue
    By Nosaj08 in forum Security
    Replies: 1
    Last Post: 07-13-2009, 10:43 AM
  5. Database Login Error
    By narasareddy in forum Access
    Replies: 0
    Last Post: 08-30-2008, 12:00 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