Security question

I

Ixtreme

I have a simple database with many fields that have an 'On not in
list' command. The current code asks for a password to continue by
means of an Inputbox. This works fine. Unfortunately, the password
information can be seen by everybody (it is not masked). Is it
possible to open a new password form and pass the password information
somehow to this 'on not in list event'? If the password is correct,
the code should continue, if not an warning.

The current code looks like this:

pw = InputBox("Enter password to continue")
If pw = "1234" Then
Set db = CurrentDb
Set rs = db.OpenRecordset(strTblName, dbOpenDynaset)
On Error Resume Next
rs.AddNew
rs!TEST = NewData
rs.Update
 
T

Tom van Stiphout

On Wed, 19 May 2010 06:45:04 -0700 (PDT), Ixtreme <[email protected]>
wrote:

Yes you can. Here are a few tips:
* Open that new form using WindowMode=acDialog, so it is modal just
like InputBox is.
* When user clicks OK or Cancel in the new form, run
"Me.Visible=False". This makes the form "fall out of the modal loop"
so the next line after DoCmd.Openform runs. In that line you can
inspect the password form to determine what password was entered, and
whether user clicked OK or Cancel. Finally you close that form
(DoCmd.Close "myPasswordForm")
* You're not handling Cancel yet in your code, but it's important.

-Tom.
Microsoft Access MVP
 
J

John Spencer

The way to do this is to open a custom form in dialog mode.
Set the Input mask for the control for entering the password to
Password
Then when the user presses the close button on the form, set the form's
visible property to NO (don't close it).


Docmd.OpenForm "frmGetPassword",,,,,acDialog
If Forms!frmGetPassword!PasswordTextBox = "1234" THEN
DoCmd.Close acForm, "frmGetPassword" 'Close the password form
Set db = CurrentDb
Set rs = db.OpenRecordset(strTblName, dbOpenDynaset)
On Error Resume Next
rs.AddNew
rs!TEST = NewData
rs.Update
ELSE
DoCmd.Close acForm, "frmGetPassword" 'Close the password form
End if


John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County
 
I

Ixtreme

The way to do this is to open a custom form in dialog mode.
Set the Input mask for the control for entering the password to
    Password
Then when the user presses the close button on the form, set the form's
visible property to NO (don't close it).

Docmd.OpenForm "frmGetPassword",,,,,acDialog
If Forms!frmGetPassword!PasswordTextBox = "1234" THEN
    DoCmd.Close acForm, "frmGetPassword" 'Close the password form
    Set db = CurrentDb
    Set rs = db.OpenRecordset(strTblName, dbOpenDynaset)
    On Error Resume Next
       rs.AddNew
       rs!TEST = NewData
       rs.Update
ELSE
    DoCmd.Close acForm, "frmGetPassword" 'Close the password form
End if

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County






- Tekst uit oorspronkelijk bericht weergeven -

I tried this but get an error 2450: MS Access cant find the form
'frmGetPassword' referred to in a Macro or Expression etc.
I created the form and it shows on the right time. After I click the
close button this warning is being displayed. Why?
 
J

John Spencer

Because you closed the form frmGetPassword. Don't close it. Use a button on
the form to set the form's visible property to false to hide the form.

Me.Visible = False

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County
 
I

Ixtreme

Because you closed the form frmGetPassword.  Don't close it.  Use a button on
the form to set the form's visible property to false to hide the form.

   Me.Visible = False

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County





- Tekst uit oorspronkelijk bericht weergeven -

John,

Thank you so much!

Kind regards,

Mark
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top