Hi
I'm playing with passwording forms and although security is not a big issue I'm finding that I'm having to add a few more passworded forms. I though about usernames and passwords but it doesn't really fit into the big picture.
I've created a function (below) that I think will do everything I want but I can't figure out (mental block) a way to set the passed form name to visible or not.
Here's the code
Option Compare Database
Global strGetWord As String
-----------------------------------------------
Function SecurityCheck(strPasswd As String, frmFormName As String, frmReferForm As String, bolCloseRefer As Boolean) As Boolean
Dim OkToGo As Boolean
Dim chances As Integer
Dim frm As Form
' Usage - Call SecurityCheck from button click on refering form
' With accept arguments and return true or false if
' frmReferForm is left blank.
'
' strPasswd is the password required to be able to open the form
' frmFormName is the form that you want to open
' frmReferForm is the form that you started from, the parent form.
' bolCloseRefer True/False whether to close the parent form or hide it
' Example; Call SecurityCheck ("password","nextform",me.name,True)
' Copyright 2003 - Howard Picken
On Error Resume Next
OkToGo = False
chances = 0
' one only gets three chances at a time to get it
Do While chances <= 3
DoCmd.OpenForm "frmpassword", , , , , acDialog
If strPasswd = strGetWord Then
OkToGo = True
Exit Do
Else
MsgBox "Password Incorrect" & (Chr(13) & Chr(10)) & "Please re-enter or Cancel", vbOKOnly
chances = chances + 1
OkToGo = False
End If
Loop
If OkToGo Then
SecurityCheck = True
If frmFormName <> "" Then
If bolCloseRefer Then
DoCmd.Close ReferForm
DoCmd.OpenForm frmFormName
Else
Set frm = Form(frmReferForm)
frm.Visible = False
DoCmd.OpenForm frmFormName
End If
End If
Else
SecurityCheck = False
End If
End Function
-------------------------------------------
Function SetWord(strPassIt As String)
strGetWord = strPassIt
End Function
--------------------------------------------
Form frmPassword calls the SetWord function when it close to pass the entered password through to the function.
How do I rewrite the following to work
Set frm = Form(frmReferForm)
frm.Visible = False
Howard
I'm playing with passwording forms and although security is not a big issue I'm finding that I'm having to add a few more passworded forms. I though about usernames and passwords but it doesn't really fit into the big picture.
I've created a function (below) that I think will do everything I want but I can't figure out (mental block) a way to set the passed form name to visible or not.
Here's the code
Option Compare Database
Global strGetWord As String
-----------------------------------------------
Function SecurityCheck(strPasswd As String, frmFormName As String, frmReferForm As String, bolCloseRefer As Boolean) As Boolean
Dim OkToGo As Boolean
Dim chances As Integer
Dim frm As Form
' Usage - Call SecurityCheck from button click on refering form
' With accept arguments and return true or false if
' frmReferForm is left blank.
'
' strPasswd is the password required to be able to open the form
' frmFormName is the form that you want to open
' frmReferForm is the form that you started from, the parent form.
' bolCloseRefer True/False whether to close the parent form or hide it
' Example; Call SecurityCheck ("password","nextform",me.name,True)
' Copyright 2003 - Howard Picken
On Error Resume Next
OkToGo = False
chances = 0
' one only gets three chances at a time to get it
Do While chances <= 3
DoCmd.OpenForm "frmpassword", , , , , acDialog
If strPasswd = strGetWord Then
OkToGo = True
Exit Do
Else
MsgBox "Password Incorrect" & (Chr(13) & Chr(10)) & "Please re-enter or Cancel", vbOKOnly
chances = chances + 1
OkToGo = False
End If
Loop
If OkToGo Then
SecurityCheck = True
If frmFormName <> "" Then
If bolCloseRefer Then
DoCmd.Close ReferForm
DoCmd.OpenForm frmFormName
Else
Set frm = Form(frmReferForm)
frm.Visible = False
DoCmd.OpenForm frmFormName
End If
End If
Else
SecurityCheck = False
End If
End Function
-------------------------------------------
Function SetWord(strPassIt As String)
strGetWord = strPassIt
End Function
--------------------------------------------
Form frmPassword calls the SetWord function when it close to pass the entered password through to the function.
How do I rewrite the following to work
Set frm = Form(frmReferForm)
frm.Visible = False
Howard