Go Back   Access World Forums > Microsoft Access Discussion > General

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 11-27-2002, 03:44 PM   #1
crann
Newly Registered User
 
Join Date: Nov 2002
Posts: 160
Thanks: 16
Thanked 0 Times in 0 Posts
crann
Unhappy Help with code???????

Hi,

I am trying to protect a command button that currently opens a standard mailing list form.

I have read through other Threads, but am new to code, i am using this code to password protect the button:

If InputBox ("Please enter your password.","Password Checkpoint") = "make_up_a_password_to_fill_in_this_space" Then
Do_this_appropriate_action
Else
Invalid_password_action
Exit Sub
End If

I am inserting the above code on the buttons 'on click' event procedure, but there is also the code (below) to open the form, in there and i don't know how the code should read, so that first it asks for a password then if correct opens the form.


Private Sub Command0_Click()
On Error GoTo Err_Command0_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Mailing List"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command0_Click:
Exit Sub

Err_Command0_Click:
MsgBox Err.Description
Resume Exit_Command0_Click

End Sub

If i insert the code that opens the form in the code above where it says 'do this appropriate action, i get all sorts of compile errors, God knows what i am doing.


Hope someone can understand this. Its blinking confusing.

Thanks Guys.....

crann is offline   Reply With Quote
Old 11-27-2002, 04:46 PM   #2
ghudson
Newly Registered User
 
ghudson's Avatar
 
Join Date: Jun 2002
Location: USA
Posts: 6,199
Thanks: 1
Thanked 89 Times in 49 Posts
ghudson has a spectacular aura about ghudson has a spectacular aura about ghudson has a spectacular aura about
Cool

This is a simple way to call an input box that allows the user to key a password and if correct it will open a form.
Assign this code to the OnClick event of the button to open the form that you want password protected.

Code:
    Dim strInput As String
    Dim strMsg As String
    
    Beep
    strMsg = "This form is used only by the ''Special Form'' people." & vbCrLf & vbLf & "Please key the ''Special Form'' password to allow access."
    strInput = InputBox(Prompt:=strMsg, title:="Special Form Password")
    If strInput = "SpecialFormPassword" Then 'password is correct
        DoCmd.OpenForm "Mailing List"
        DoCmd.Close acForm, Me.Name
    Else 'password is incorrect
        MsgBox "Incorrect Password!" & vbCrLf & vbLf & "You are not allowed access to the ''Special Form''.", vbCritical, "Invalid Password"
        Exit Sub
    End If
You can not format an input box!

HTH
__________________
.................................................. ......
Searching this forum or Microsoft.com or MSDN.com or Google is a great way to discover and learn the answers to your Access programming questions.

Well if it seems to be real, it's illusion...

I am using Access 2010 with Windows 7

The
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
function on this forum really does work.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

.................................................. ......
ghudson is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump




All times are GMT -8. The time now is 07:53 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World