VBA code to Restrict Access to an access form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • AccessHunter
    New Member
    • Nov 2007
    • 77

    VBA code to Restrict Access to an access form

    I am working on an access database wthat has a main form and other multiple forms. The main form has buttons that when clicked will take user to the respective forms. I want to restirct access to couple of forms so that only our admin will have access to it. Is it possible to do that using VB? Please help.

    Thanks
  • Dököll
    Recognized Expert Top Contributor
    • Nov 2006
    • 2379

    #2
    Either VB or VBA should, I reckon you have something working already! Would you like to post it?

    Provided your users are hitting a button to get to other forms, you'd need to have perhaps a password block.

    I will add to VBA area for an idea, much later, will leave your post here though in VB for a closer look. But here's an excerpt of my code in a current MS Access form where a certain form needs a Password...

    I won't post the whole thing, but you'll ge the point:

    [CODE=VBA]
    Dim strPassword

    strPassword = InputBox("Pleas e Enter Passcode", "Data Central Restricted Form")

    'Check to see if there is any entry made to input box, or if
    'cancel button is pressed. If no entry made then exit sub.

    If strPassword = "" Or strPassword = Empty Then
    MsgBox "No Input Provided; please enter passcode to continue...", vbInformation, "Data Central Required Data"
    Me.Visible = False
    DoCmd.OpenForm "DataData", acNormal
    Exit Sub

    End If

    'If correct and part of passcode is entered open Passcode form
    'If entire passcode is entered open RestrictedPsswr dForm form
    'If incorrect passcode entered give message and exit sub

    If strPassword = "MyPassportPass code" Then
    DoCmd.OpenForm "Passwords" , acNormal 'the form noone should get to
    ElseIf strPassword = "MyPasswordPass code" Then

    'send user elsewhere...

    [/CODE]

    If this does not do, or you need anything further please stay tuned, and do post what you have thus far, for looks; seems to be a bit quicker for your posts to get real hits:-)

    In a bit!
    Last edited by Dököll; Nov 26 '08, 05:13 AM. Reason: text...

    Comment

    Working...