enable disable

  • Thread starter mike via AccessMonster.com
  • Start date
M

mike via AccessMonster.com

hi
i have a form and a subform it works fine. Now my question is i have a button
command(to edit) on my mainform. the button command will open a form to check
a password to enter. i wanted to enable a certain field from my mainform if
only if the password entered by user is correct and if not i want my fields
as it is.

(code of my edit button)
Private Sub Edit_Click()
On Error GoTo Err_edit_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmpassedit"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Me.MC_Req_.SetFocus
Exit_edit_Click:
Exit Sub

Err_edit_Click:
Err.Description
Resume Exit_edit_Click

End Sub
(code of my password form)
Private Sub checkpaassword_Click()
If IsNull(Forms!frmpassedit!Text0.Value) Then
MsgBox "It is not a blank Password...Try again."
Me!Text0.SetFocus

End If
If (Forms!frmpassedit!Text0 <> "vincent") Then
MsgBox "Wrong Password...Try again."
Me!Text0.SetFocus
End If
If (Forms!frmpassedit!Text0 = "vincent") Then
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmAncReq"
DoCmd.OpenForm stDocName, , , stLinkCriteria

DoCmd.Close acForm, Me.NAME

End If
End Sub

Private Sub Command4_Click()

DoCmd.Close acForm, "frmpassEdit"
End Sub

i want to enable the field on main form only if the password is correct:

thanks for any help
 
L

Lee Robinson

Mike,

You can enable the fields from your password form. Suppose the name of form
with the fields is frmEditSalary and the field to enable is txtSalary, then
in frmPassEdit you can issue this command:

If (Forms!frmpassedit!Text0 = "vincent") Then
[Form_frmEditSalary].[txtSalary].Locked = false
Else
[Form_frmEditSalary].[txtSalary].Locked = true
End if

Controls on a form are "public" and can be set from other forms.

Lee Robinson
 
J

jervin0831 via AccessMonster.com

thanks ill try this...

Lee said:
Mike,

You can enable the fields from your password form. Suppose the name of form
with the fields is frmEditSalary and the field to enable is txtSalary, then
in frmPassEdit you can issue this command:

If (Forms!frmpassedit!Text0 = "vincent") Then
[Form_frmEditSalary].[txtSalary].Locked = false
Else
[Form_frmEditSalary].[txtSalary].Locked = true
End if

Controls on a form are "public" and can be set from other forms.

Lee Robinson
hi
i have a form and a subform it works fine. Now my question is i have a
[quoted text clipped - 53 lines]
thanks for any help
 

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