Results 1 to 4 of 4
  1. #1
    5 Star Lounger
    Join Date
    Jul 2004
    Location
    Ohio
    Posts
    629
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Access If then VBA question (2k)

    i have a table that has a list of users in it. i want to put in a check to make sure that the user exists in the table before they get access to the program. so in form load, i want to have an if then statement to check to see if the user exists in the table. how do i check to see if a user does or does not exist though?

    right now this is what i have:

    vUser = getuserfunction

    If IsNull(vUser) Then
    'Close Application
    MsgBox "Not Authorized", vbCritical
    DoCmd.Quit
    End If

    would this work? or do i need to do a lookup type of thing?
    <img src=/w3timages/blueline.gif width=33% height=2>
    <big>John</big>

  2. #2
    5 Star Lounger
    Join Date
    Jul 2004
    Location
    Ohio
    Posts
    629
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Access If then VBA question (2k)

    let me clear that up a little. vUser is a function that gets the user from WINNT logon. So really that would never be null, i need to look up the vUser in my table to get the user's permissions. However if that user is not in the table, i need to restrict access and close the DB. and now that i think of it, that makes my if then statement way off <img src=/S/doh.gif border=0 alt=doh width=15 height=15>
    <img src=/w3timages/blueline.gif width=33% height=2>
    <big>John</big>

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Access If then VBA question (2k)

    A DLookup is the ticket here.

    vUser = getuserfunction
    If IsNull(DLookup("SomeField", "UserTable", "UserName = " & Chr(34) & vUser & Chr(34))) Then
    MsgBox "<insert insulting text here>", vbCritical
    Application.Quit
    End If

  4. #4
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: Access If then VBA question (2k)

    It appears to me you are trying to roll your own user security using the NT login values. For numerous reasons, it really doesn't work all that well - just one example is there isn't any way to prevent users from messing with tables and table designs at the NT login level. Access User Security will handle those kind of issues, but involves using another login process and the additional administration involved with it. If you aren't familiar with the subject, you might find our User Security Tutorial useful.
    Wendell

Posting Permissions

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