login then filter by user

alkrm

Registered User.
Local time
Today, 23:50
Joined
Aug 13, 2003
Messages
39
hey
at the start of my data base, u have a log on form, and then u will go to another form where u will have the information .
can we sort"filtere" the forms by the log in user ?

i mean , if the user name is "X", this is on a log in form.
then the other forms will be filtered Related to X.
while x have a unique field for use in the table.

thnx
 
If you've got Access security running, you can use the CurrentUser() function. Else read this thread for more info: Get NT Userid.
 
hi , thanx for ur reply ,
check this out, i used the wizard and i could filter one form upon the text box i am using for entering the user name, this is the code"text1 is the user name ","name a field in the info form":

Private Sub log_on_Click()
On Error GoTo Err_log_on_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "info" ' name of the form to be open

stLinkCriteria = "[name]=" & "'" & Me![Text1] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_log_on_Click:
Exit Sub

Err_log_on_Click:
MsgBox Err.Description
Resume Exit_log_on_Click

End Sub

problem :
i have another forms i want to filter without open it


any idea?? thnx anyway
 
Great! Most users don't trust their users enough to allow them to enter any old user ID and want to take information directly from Access or Windows, but whatever works.

i have another forms i want to filter without open it
I don't quite understand. You want to filter a form without opening it?
 
what i mean is, all the forms that has information about the user will be filter upon his log in name, so he can't see the others records , not only the one form
"filter all the forms without open it " , caz the forms r closed , but the user might open it later ,
so is there is a way to do that ?

thnx again
 
filter on login

I am looking for the same type of thing, is there something that will act as a login identifier (dialog box, form, ???) and when filled in filter all records except those related to this person (or service) so only the records they should be accessing they are allowed to see?
 
alkrm & belsha,

The first that you need is to know who
is using your application. As DCX said,
if you are using Access Security just
use CurrentUser() and filter the records
as alkrm did in his post.

If you don't have Access Security running
they an alternative is to use the routine
that DCX posted to get the Windows username.

If you go with neither of the above. You
can use the textbox and/or a combobox to
let the user enter/select their name. Here
though, you lose control.

The next logical step is to create a table
with username, password, and maybe even a
category (admin, manager, clerk). This
way when your app opens, you can bring up
a nice form to ask them who they are and
their password.

Then, hide the form (so that you can retain
its values) or save the name, category etc.
to a global variable.

Then you can use this information whenever
launching a form or report.

Wayne
 

Users who are viewing this thread

Back
Top Bottom