Full Version: Form Enable Property Sheets
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
rjAccDB
Hello UA,

I have a form being locked by the below code;

-
Form_frmCorrFilter.AllowEdits = False
Form_frmCorrFilter.AllowAdditions = False
Form_frmCorrFilter.AllowFilters = False
Form_frmCorrFilter.AllowDeletions = False
-

How can I make all these into "TRUE" on a button click, but I need to protect it by a password.

Many thanks for the help.
rj
Kauchais
Are you going to use windows login password or one just for this?
freakazeud
Hi,
one possible solution would be utilizing the InputBox() function on the on click event of the button e.g.:

Dim strInput As String
Dim strMsg As String

strMsg = "Enter Password!"

strInput = InputBox(Prompt:=strMsg, title:="Enter Password:")

If strInput = "YourPassWord" Then
'set properties to true
Else
MsgBox("Wrong Password...sorry!")
End If

This is obviously not very secure...but it all depends on what you need.
HTH
Good luck
rjAccDB
Hi,

That was very quick.

Ok, my form is opened it is locked, before the user can make enable for edit, it need to click a button, but before it completely enabling the form it needs to enter the set password.

Hope that make sense.

rj
rjAccDB
Hi Oli,

You have a sharp mind!..

I will try it.

Thanks,
rj
freakazeud
You're welcome.
Good luck.
Kauchais
two options have freakazeud code run when they open the form or when they click a button on the form.
if a button on the form in the event proc. on click for the button have

Dim strInput As String
Dim strMsg As String

strMsg = "Enter Password!"

strInput = InputBox(Prompt:=strMsg, title:="Enter Password:")

If strInput = "YourPassWord" Then
Form_frmCorrFilter.AllowEdits = true
Form_frmCorrFilter.AllowAdditions = true
Form_frmCorrFilter.AllowFilters = true
Form_frmCorrFilter.AllowDeletions = true
Else
MsgBox("Wrong Password...sorry!")
End If

or you could save the password on a table of users and ask for user then password.
rjAccDB
Hello Oli,

That works for the purpose, many many thanks,

rj
freakazeud
You're welcome. sad.gif
Glad I could assist.
Good luck on future projects!
rjAccDB
Hi Oli,

Now how can I customise the dialog box title, instead of displaying "Microsoft Office Access" I want to display the name of my DB..

Sorry for asking to much,
rj
freakazeud
Hi,
check the syntax of the InputBox() function. The whole syntax is:

InputBox(prompt [, title ] [, default ] [, xpos ] [, ypos ] [, helpfile ] [, context ] )

Another approach would be to use a custom form which you format to look like you want and open up to enter the password in a control on the form. This would give you some more flexibility.
You might also find this sample helpful.
HTH
Good luck
rjAccDB
Hello Kauchais,

Thank you, you both a genius - the last line "or you could save the password on a table of users and ask for user then password" is a bit advance to my level.

Thanks,
rj
rjAccDB
Many thanks Oli...
freakazeud
No problemo... thumbup.gif
rjAccDB
Hi Oli,

Am trying to play around with the customization of MsgBox thing but not able to do it.

I have examined your demo db's, copy some MsgBox format and try to change some entries but I always got the Microsoft Visual Basic Error Dialog saying (Compile error: Expected:=). Am totaly lost.

Just want to put customized title, instead of Microsoft Office Access.

Maybe Im just too dumb to follow syntax....
freakazeud
Can you post what you have been trying to use?
HTH
Good luck
rjAccDB
Hi Oli,

Thanks for your time, I think I sorted out by removing the "( )" as below;

--
from... MsgBox ( "Wrong Password...", vbInformation, "User Validation")

to... MsgBox "Wrong Password...", vbInformation, "User Validation"
--

I don't if this is the correct way, but it did what I wanted..

Oli, thank you very much once again.

rj


Edited by: ksalearnsaccess on Thu Feb 15 0:43:03 EST 2007.
freakazeud
Yes...that is the correct way.
Glad you got it sorted out.
Good luck on future projects!
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.