Unlocking fields

E

Eric G

I'd like to be able to code so that when a particular UserID logs in
via a password form, several control fields on another form are
unlocked and then locked again when that form is closed.

The UserID is entered in a control called cboUserID on a form named
'frmPassword'. The control has three columns, the first containing the
UserID.

The tab form that has the control fields that need to be unlocked is
called 'frmTab'. On frmTab's 2nd tab there lies two forms:
Parent form called 'frmTabStudent' and subform called
'frmTabStudentSub'

The control fields that I'd like to unlock are on this
'frmTabStudentSub'.

Guidance on the commands to unlock and lock several fields would be
greatly appreciated! I hope I've provided enough info.

TIA Eric
 
V

Van T. Dinh

In the Form_Load Event of the Form "frmTab", use something like:

If Forms!frmPassword!cboUserID.Value = {whatever} Then
With Me.SubformControl.Form
.Control.Enabled = True
.Control.Locked = False
....
End With
End If

Note that the name of the Subform*Control* may be *different* from the name
of the Form ("frmTabStudentSub") being used as the Subform (more technically
accurate, being used as the SourceObject of the SubformControl).
 
E

Eric G

Hi Van,

Thanks for your help, I appreciate it.

I wasn't sure what to put in for the values.
I put in:

If Forms!frmPassword!cboUserID.Value = EGR Then
With Me.frmTabStudentSub.Form
.Control.Enabled = True
.Control.Locked = False
End With
End If

Maybe I'm way off still? Anyways, what happened was the Password form
came up, I entered UserID and Password. Then the main Tab form opened
but closed right away and the Password form opened again. Stuck in
that loop.

Again here are the names of forms, controls:
frmPassword
frmTab
Page1 of frmTab has
frmTabStudent
frmTabStudentSub (subform)
controls on this subform that I need unlocked are:
Status, TeacherID, Reason


I thought of another general way to go about this if it might be
easier. Instead of linking my password to this subform, perhaps imbed
a double-click event on a label on this subform and have the unlock
commands work from this event? If this would be easier I'd be OK with
it.
I still wouldn't know the commands to put into the event though.

TIA Eric
 
V

Van T. Dinh

What is "EGR"?

How do you check the entered password matches with the password of the
seleted user?
 
E

Eric G

Hi Van,
What is "EGR"?

EGR is 1 of 60 user ID's that can be entered in the password form.

How do you check the entered password matches with the password of the
seleted user?

If Not IsNull(Me!cboUserID) Then
If Me!txtPassword = Me!cboUserID.Column(1) Then

'Log User into LogUser table
DoCmd.SetWarnings False
DoCmd.OpenQuery "LogUserInQry", acNormal, acEdit
DoCmd.SetWarnings True
'Open frmTab
DoCmd.OpenForm "frmTab"
End If


Thanks again! Eric
 
V

Van T. Dinh

Since it is a String, you should use:

If Forms!frmPassword!cboUserID.Value = "EGR" Then
...

Make sure the BoundColumn of the ComboBox is the one that gives "EGR" or
similar values.
 
E

Eric G

Since it is a String, you should use:
If Forms!frmPassword!cboUserID.Value = "EGR" Then
...

Make sure the BoundColumn of the ComboBox is the one that gives "EGR" or
similar values.

OK, cboUserID.Value wasn't working but when I changed it to .Column(1)
I was able to get past the password form and open the frmTab without
looping back to the password form.


If Forms!frmPassword!cboUserID.Column(1) = "EGR" Then
With Me.frmTabStudent.Form
' With Me.frmTabStudentSub.Form (frmTab closes and I return to

frmpassword)
.Control.Enabled = True
.Control.Locked = False
.Status.Locked = False
.TeacherID.Locked = False
.Reason.Locked = False
End With
End If

Now I need to somehow adjust the code after that because the controls
(status, teacherID, and Reason) remain locked.
Again the structure is like this:
frmTab has 4 tabs. The second tab has a form and subform on it.
frmTabStudent and subform frmTabStudentSub.
The controls that I'd like to unlock are on the subform and are
Status, TeacherID and Reason.

Eric
 
V

Van T. Dinh

Try:

With Me!SubformControlName.Form!SubSubFormControlName
...

Note: the SubformControlName and SubSubformControlName may or may NOT be
"frmTabStudent" & "frmTabStudentSub".

You need to check the (Sub)SubformControlNames in the DesignView of the Form
/ Subform.
 
E

Eric G

Hi Van,
Try:

With Me!SubformControlName.Form!SubSubFormControlName
...

Note: the SubformControlName and SubSubformControlName may or may NOT be
"frmTabStudent" & "frmTabStudentSub".

You need to check the (Sub)SubformControlNames in the DesignView of the Form
/ Subform.


I didn't have success getting the controls to change to unlocked but
I came up with another solution.

I've created another front-end .mdb file with the controls in
question changed from locked to unlocked.
I'll simply open this front-end .mdb file when I need to make changes
to the data quickly.

Thanks for your help! Eric
 

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