Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2008
    Posts
    3

    Unanswered: I must filter data by user

    Excuse me for my english.
    I’ve got a Access2003 Db and I must enter by User and PWD and view all table’s rows that have column with data equal to USER.
    How? Can you write all steps..
    Thanks

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    it depends on how and where the userid is set

    in essence you need toselect thoise records which that user edited/created
    that means adding a where clause to your query. that can be done in SQL of the query browser
    where userid = currentuser()

    but possibly the easiest would be to apply a filter so that the form only returns rows with the userid = the required value. ifyou go down the filter orute then make sure you do not allow users to apply or remove filters.
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Oct 2008
    Posts
    3
    How? can you write code to ask access user and to select data by this?
    Thank you

  4. #4
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    You first need a "Security" table with 2 fields. These are SecurityLevelField and LoginID (along with password fields and other fields you may have.) SecurityLevelField is an int value (or string.) You assign a number for each LoginID. This is their security level (you can make it so 1s are the highest or 1s are the lowest.)

    Now when they open the form, ask them to enter their LoginID (LID) and then Dlookup to get the security level. Then just write a case statement to configure the locking/enabling/visible schemes for each of the controls.

    Dim LID as variant
    LID = inputbox("Enter your login ID:")
    dim SecLevel as integer
    SecLevel = dlookup([SecurityLevelField]","MytableName","[LoginID = '" & LID & "'")
    select case SecLevel
    case 1
    me.FieldXXXX.locked = true
    me.FieldYYYY.enabled = false
    me.cmdButtonXXXX.enabled = false
    me.allowadditions = false
    me.cmdPrintButton.visible = false
    case 2
    ....
    ....
    ....
    End select
    Last edited by pkstormy; 10-23-08 at 21:34.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  5. #5
    Join Date
    Oct 2008
    Posts
    3
    Thank you very much

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •