Combo Box Filter according to user log in

F

fpcsql

Please help me with the following which is driving me insane:
In my application, users are required to log in - not using microsoft
security. Have table with userid, username, password and level of access
allowed per user. (security table)

These users will choose items from a combo box to print. The problem lies in
restricting each user to print only his / her allowed items (at a record
level) from the detail table.

So this combo box lists the items found in the detail table on condition
that the userid = the user id on the security table for the user logged in at
that time.

I have stored the userid as a public variable in a module, but am still
having problems in restricting the data list displayed in the combo box. I
think there is something wrong with my syntax.

Dim rst As Object
Dim uid As String

Set rst = Me.Recordset.Clone
uid = User.SecurityID

rst.FindFirst "[SchemeName] = '" & Me![scheme] & "'" & "[UserID] = '" &
uid & "'"

rst.Close

Another question is would it be a problem storing the userid as a public
variable, since it is a multi-user application?

I'd appreciate any help - Thanks
 
C

Carl Rapson

fpcsql said:
Please help me with the following which is driving me insane:
In my application, users are required to log in - not using microsoft
security. Have table with userid, username, password and level of access
allowed per user. (security table)

These users will choose items from a combo box to print. The problem lies
in
restricting each user to print only his / her allowed items (at a record
level) from the detail table.

So this combo box lists the items found in the detail table on condition
that the userid = the user id on the security table for the user logged in
at
that time.

I have stored the userid as a public variable in a module, but am still
having problems in restricting the data list displayed in the combo box. I
think there is something wrong with my syntax.

Dim rst As Object
Dim uid As String

Set rst = Me.Recordset.Clone
uid = User.SecurityID

rst.FindFirst "[SchemeName] = '" & Me![scheme] & "'" & "[UserID] = '" &
uid & "'"

rst.Close

Another question is would it be a problem storing the userid as a public
variable, since it is a multi-user application?

I'd appreciate any help - Thanks

Your FindFirst syntax is wrong. It should be:

rst.FindFirst "[SchemeName] = '" & Me![scheme] & "' AND [UserID] = '" &
uid & "'"

As for your other question, it shouldn't be a problem because each user has
a separate copy of the application loaded into memory. However, for
integrity reasons, I would suggest splitting the application and placing a
copy of the "front-end" (forms etc) onto each user's PC and the "back-end"
(tables) on a server. Search the newsgroups for more information about
splitting and maintaining the front-end.

Carl Rapson
 
K

Klatuu

Carl is correct about the userid issue. If you are using one front end
database for all users, the public variable will contain the userid of the
last person that logged on.
Always split your database
Always deploy a copy to each user on thier desktop, Not on a network drive.
 
F

fpcsql

Thanks VERY much to both Carl and Dave - much appreciated!

Klatuu said:
Carl is correct about the userid issue. If you are using one front end
database for all users, the public variable will contain the userid of the
last person that logged on.
Always split your database
Always deploy a copy to each user on thier desktop, Not on a network drive.
--
Dave Hargis, Microsoft Access MVP


fpcsql said:
Please help me with the following which is driving me insane:
In my application, users are required to log in - not using microsoft
security. Have table with userid, username, password and level of access
allowed per user. (security table)

These users will choose items from a combo box to print. The problem lies in
restricting each user to print only his / her allowed items (at a record
level) from the detail table.

So this combo box lists the items found in the detail table on condition
that the userid = the user id on the security table for the user logged in at
that time.

I have stored the userid as a public variable in a module, but am still
having problems in restricting the data list displayed in the combo box. I
think there is something wrong with my syntax.

Dim rst As Object
Dim uid As String

Set rst = Me.Recordset.Clone
uid = User.SecurityID

rst.FindFirst "[SchemeName] = '" & Me![scheme] & "'" & "[UserID] = '" &
uid & "'"

rst.Close

Another question is would it be a problem storing the userid as a public
variable, since it is a multi-user application?

I'd appreciate any help - Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top