UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Login Form    
 
   
campo88
post Dec 24 2009, 07:15 PM
Post #1

UtterAccess Enthusiast
Posts: 68



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.

Merry Xmas



Edited by: campo88 on Thu Dec 24 19:16:21 EST 2009.
Go to the top of the page
 
+
pbaldy
post Dec 24 2009, 07:52 PM
Post #2

UtterAccess VIP
Posts: 5,052
From: Nevada, USA



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.
Go to the top of the page
 
+
campo88
post Dec 24 2009, 08:02 PM
Post #3

UtterAccess Enthusiast
Posts: 68



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?
Go to the top of the page
 
+
pbaldy
post Dec 24 2009, 09:07 PM
Post #4

UtterAccess VIP
Posts: 5,052
From: Nevada, USA



Presuming you have it on one of the forms:

Forms!FormName.TextboxName
Go to the top of the page
 
+
theDBguy
post Dec 25 2009, 12:20 AM
Post #5

Access Wiki and Forums Moderator
Posts: 48,097
From: SoCal, USA



Hi,

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...
Go to the top of the page
 
+
campo88
post Dec 25 2009, 03:08 PM
Post #6

UtterAccess Enthusiast
Posts: 68



Hi

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.
Go to the top of the page
 
+
pbaldy
post Dec 25 2009, 03:22 PM
Post #7

UtterAccess VIP
Posts: 5,052
From: Nevada, USA



The syntax would be different for text:

http://www.baldyweb.com/wherecondition.htm
Go to the top of the page
 
+
theDBguy
post Dec 25 2009, 03:28 PM
Post #8

Access Wiki and Forums Moderator
Posts: 48,097
From: SoCal, USA



Hi,

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...
Go to the top of the page
 
+
pbaldy
post Dec 25 2009, 04:32 PM
Post #9

UtterAccess VIP
Posts: 5,052
From: Nevada, USA



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.
Go to the top of the page
 
+
theDBguy
post Dec 25 2009, 04:44 PM
Post #10

Access Wiki and Forums Moderator
Posts: 48,097
From: SoCal, USA



Hi Paul,

Your suggestion was excellent. Between the two of us, I just wanted to make sure all bases were covered.

Cheers.
Go to the top of the page
 
+
campo88
post Dec 25 2009, 05:38 PM
Post #11

UtterAccess Enthusiast
Posts: 68



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.
Go to the top of the page
 
+
theDBguy
post Dec 25 2009, 10:19 PM
Post #12

Access Wiki and Forums Moderator
Posts: 48,097
From: SoCal, USA



Hi,

If you don't want the user to enter "new" records, change the form's Allow Additions property to "No."

Hope that helps...
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 24th May 2013 - 02:59 PM