Dec 24 2009, 07:15 PM
I have a login form for users to enter their user_id and password. If successfull the login form closes and my main form opens.
This main form is linked to a table that has users details. I only want the users to see their own information and no-one elses. My first thought was to hide all other users, however I am not sure how to do this and whether this is the best way.
I hope you can help.
Edited by: campo88 on Thu Dec 24 19:16:21 EST 2009.
Dec 24 2009, 07:52 PM
You can base the main form on a query that uses the user from the login form to restrict the records. Rather than close the login form you can just hide it so the user ID is always available. You can also copy it to a hidden textbox on the main form before closing the login form.
Dec 24 2009, 08:02 PM
Basically you are saying that I need the user_id that is input to be stored so I can use this to query?
I am not very good at the querying this. What criteria do I need to put in?
Dec 24 2009, 09:07 PM
Presuming you have it on one of the forms:
Dec 25 2009, 12:20 AM
Pardon me for jumping in...
If you are saying that you want the user who just logged in to only see their account details on the main form, then you could try changing the code you have for opening the main form to something like:
DoCmd.OpenForm "MainFormName", , , "user_id=" & Me!user_id
Hope that helps...
Dec 25 2009, 03:08 PM
This code does not seem to work. The error I am getting back is:
"The expression you entered refers to an object that is closed or does not exist"
is it because my user_id is a text format?
I look forward to your answer.
Dec 25 2009, 03:22 PM
Dec 25 2009, 03:28 PM
With regards to the error you're getting, it sounds like you are closing the Login form before you open the main form. Try switching the codes around. Open the main form first before closing the Login form.
Just my 2 cents...
Dec 25 2009, 04:32 PM
Good point DBguy. I should point out that the reason I suggested the other alternative to begin with is that using the wherecondition is a little less secure, if you're worried about users seeing other users records. Leigh has posted in detail on this, but the essence of it is that the wherecondition applies a filter, which a user can conceivably remove and view all records.
Dec 25 2009, 04:44 PM
Your suggestion was excellent. Between the two of us, I just wanted to make sure all bases were covered.
Dec 25 2009, 05:38 PM
Finally got it to work thanks, but strangely when the form opens i can select next record. The current record goes to 2 of 2, but the form has all blank data. Any idea why this might be happening.
Thanks for all your help peeps.
Dec 25 2009, 10:19 PM
If you don't want the user to enter "new" records, change the form's Allow Additions property to "No."
Hope that helps...
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here