Results 1 to 3 of 3

Thread: Check Table

  1. #1
    Join Date
    May 2005

    Unanswered: Check Table

    First off, everything I know about programming databases I've either read in various books, taught myself, or learned from you guys on this form. So my apologies in advance if this is a dumb question.

    I have a table in a database that has a list of users. I also have a form that is used to add records to another table (the primary information table). The database is accessible to many people on the network, but I only want certain people (that are in the users table) to be able to add a record to the information table using the aforementioned table.

    I used this site to capture the user's login (which is a field in the user's table).

    My question is, what kind of code do I use to check this name against the table?

    The table is constantly changing, so I don't want to do a
    PHP Code:
    If usersname nameA or usersname nameB ...
    'deny access
    end if 
    because then I would have to change the code every time I change the table (which seems to be a waste of time and energy). It seems there has to be a way, I just don't know it.

    Thanks in advance to anyone who can help.
    Me.Geek = True

  2. #2
    Join Date
    Mar 2003
    The Bottom of The Barrel
    Provided Answers: 1
    Create a security table. For flexibility, I would recommend using a role-based security schema, like so:




    Right then, now you create a roll called "Form Access" or whatever it is. Then:

    If DCount("user_role_id", tblUserRoles, "user_id = " & MyUserId & " AND role_id = " & MyRoleId) > 0 Then
    'Authentication passed
    'None for you!
    End If

    If you want to get REALLY crazy, you can add a group role schema that sits along side that as well. Then create a user object that populates a collection of available roles based on the combined list of roles available to that particular user, as well as any groups that user is a member of.
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  3. #3
    Join Date
    May 2005
    Nevada, USA
    Provided Answers: 6
    The simpler way is to use a DCount; the more efficient way is to open a recordset. In either case you include a criteria of that user, so nothing is returned if they aren't in the table. Then test for that.

Posting Permissions

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