Password Protect a checkbox

J

JNariss

Hello,

I have a form that we use for employee status changes (such as new hire
and terminate). I am creating a section within the form to allow users
to select various security requests (such as which apps. will be
installed and what they need security to). I included an area on my
form where you can check the box to request security. Checking this box
opens up my additional sections of security.

I was wondering if there is a way I can put a password onto that
checkbox so if a user checks it requesting the security sections they
must enter a password before they can just go in and select whatever
they want.

Does anyone know if there is there a way to do this?
 
G

Greg Collins [InfoPath MVP]

You can try using code in an OnBeforeChange or OnAfterChange event handler.

--
Greg Collins [InfoPath MVP]
Visit http://www.InfoPathDev.com


Hello,

I have a form that we use for employee status changes (such as new hire
and terminate). I am creating a section within the form to allow users
to select various security requests (such as which apps. will be
installed and what they need security to). I included an area on my
form where you can check the box to request security. Checking this box
opens up my additional sections of security.

I was wondering if there is a way I can put a password onto that
checkbox so if a user checks it requesting the security sections they
must enter a password before they can just go in and select whatever
they want.

Does anyone know if there is there a way to do this?
 
J

JNariss

I have found how to edit/add code to the OnBeforeChange in the Event
Handler except I am unsure of how to start the code. In my other
database in Access I use the following code:

Private Sub cmdOK_Click()

On Error GoTo ErrorHandler

If IsNull(Me.txtPassword) Then
MsgBox "Please enter a password " _
& "before continuing.", _
vbExclamation, "Missing Password"
GoTo ExitPoint
End If

Dim EnteredPassword As String

EnteredPassword = Me.txtPassword

Select Case EnteredPassword
Case "Red"
' Code here to open that
' person's report and/or form
DoCmd.OpenForm "Submit To Production"
DoCmd.Close acForm, "frmPassword"
'Case "Orange"
' Code here to open that
' person's report and/or form
'Case "Yellow"
' Code here to open that
' person's report and/or form
'Case "Green"
' Code here to open that
' person's report and/or form
'Case "Blue"
' Code here to open that
' person's report and/or form
'Case "That funky bright yellow " _
& "on the new Oregon Duck's uniform"
' Code here to open that
' person's report and/or form
Case Else
MsgBox "The password you have " _
& "entered is invalid. Please " _
& "re-enter.", vbExclamation, _
"Invalid password"
End Select

ExitPoint:
Exit Sub

ErrorHandler:
MsgBox Err.Description, vbCritical, _
"Error #" & Err.Number
Resume ExitPoint
End Sub




I was just wondering how to start the Private Sub............. what
would I enter after that? Private Sub OnBeforeChange_CheckBox()??

Thanks,
Justine
 
J

JNariss

Okay so here is what I tried and it told me the first line was an error
and it expected ";"

function msoxd__MacForm_SecurityOptions_attr::OnBeforeChange(eventObj)
{
// Write your code here
// Warning: ensure that the constraint you are enforcing is compatible
with the default value you set for this XML node.
Private Sub SecurityOptions_OnBeforeChange()
On Error GoTo ErrorHandler

If IsNull(Me.txtPassword) Then
MsgBox "Please enter a password" _
& "before continuing.",_
vbExclamation, "Missing Password"
GoTo ExitPoint
End If

Dim EnteredPassword As String

EnteredPassword = Me.txtPassword

Select Case EnteredPassword
Case "password"
Case Else
MsgBox "The password you have" _
& "enters is invalid. Please" _
& "contact the Help Desk.", vbExclamation, _
"Invalid Password"
End Select

Exit Point:
Exit Sub

ErrorHandler:
MsgBox err.Description, vbCritical, _
"Error #" & err.Number
Resume ExitPoint

End Sub
}


If anyone could help here I would really appreciate it.
 
S

S.Y.M. Wong-A-Ton

The scripting language in InfoPath is probably set to JScript instead of
VBScript (see the "Default programming language" field on the "Design" tab
accessed through the Tools > Options menu), which is why you are getting the
error. In addition, you cannot just copy and paste an entire VBA Sub into an
InfoPath function. You'll need to look at how you can convert your Sub into
an InfoPath function or event handler more closely.
 
J

JNariss

Thanks for the reply. I changed the Default Programming Language to
VBScript. Do you know anything about how I would go about converting my
script or possibly point me into the right direction?

-Justine
 

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