Unable to Lock/unlock form

  • Thread starter DMUM via AccessMonster.com
  • Start date
D

DMUM via AccessMonster.com

Hello, I have a form that has multiple tabs. On one of the tabs I have a
button that updates a the table behind the forms with a date or deleted the
date depending upon if an issue is open or closed. After the date field is
updated, when a user opens another tab on the form, the form should be locked
or unlocked. Originally the lock was working, but the unlock was not. Now I
can get neither to work. Can anyone help me figure out what I am missing?
Here is my code:

If Nz(DLookup("WF_StartDate", "tblWF_Shop", "WF_Shop_Key =" & Forms!
hfrmGlobal!txtCurrWorkfile & ""), 0) <> 0 Then
If Nz(DLookup("WF_CompleteDate", "tblWF_Shop", "WF_Shop_Key =" & Forms!
hfrmGlobal!txtCurrWorkfile & ""), 0) Then
Me!sfrmWFLine.Locked = True
Me!sfrmWFLine.Form.cmdAddLine.Enabled = False
Me!sfrmWFLine.Form.cmdRecalc.Enabled = False
Me!sfrmWFLine.Form.cmdDeleteLines.Enabled = False
Me!sfrmWFDiscCustNote.Form.WF_DiscountAmt.Locked = True

Else
Me!sfrmWFLine.Locked = False
Me!sfrmWFLine.Form.cmdAddLine.Enabled = True
Me!sfrmWFLine.Form.cmdRecalc.Enabled = True
Me!sfrmWFLine.Form.cmdDeleteLines.Enabled = True
Me!sfrmWFDiscCustNote.Form.WF_DiscountAmt.Locked = False

End If
End If

If I go close the form and go back into the form, the form is locked/unlocked
correctly. As I said earlier, I know there is a possibility that I was
locking/unlocking the wrong subform, however, the lock was working fine using
the same code above.

Thanks
 
S

Stuart McCall

DMUM via AccessMonster.com said:
Hello, I have a form that has multiple tabs. On one of the tabs I have a
button that updates a the table behind the forms with a date or deleted
the
date depending upon if an issue is open or closed. After the date field
is
updated, when a user opens another tab on the form, the form should be
locked
or unlocked. Originally the lock was working, but the unlock was not.
Now I
can get neither to work. Can anyone help me figure out what I am missing?
Here is my code:

If Nz(DLookup("WF_StartDate", "tblWF_Shop", "WF_Shop_Key =" & Forms!
hfrmGlobal!txtCurrWorkfile & ""), 0) <> 0 Then
If Nz(DLookup("WF_CompleteDate", "tblWF_Shop", "WF_Shop_Key =" & Forms!
hfrmGlobal!txtCurrWorkfile & ""), 0) Then
Me!sfrmWFLine.Locked = True
Me!sfrmWFLine.Form.cmdAddLine.Enabled = False
Me!sfrmWFLine.Form.cmdRecalc.Enabled = False
Me!sfrmWFLine.Form.cmdDeleteLines.Enabled = False
Me!sfrmWFDiscCustNote.Form.WF_DiscountAmt.Locked = True

Else
Me!sfrmWFLine.Locked = False
Me!sfrmWFLine.Form.cmdAddLine.Enabled = True
Me!sfrmWFLine.Form.cmdRecalc.Enabled = True
Me!sfrmWFLine.Form.cmdDeleteLines.Enabled = True
Me!sfrmWFDiscCustNote.Form.WF_DiscountAmt.Locked = False

End If
End If

If I go close the form and go back into the form, the form is
locked/unlocked
correctly. As I said earlier, I know there is a possibility that I was
locking/unlocking the wrong subform, however, the lock was working fine
using
the same code above.

Thanks

This line:
Me!sfrmWFLine.Locked = False

is missing a .Form, ie it should read:

Me!sfrmWFLine.Form.Locked = False
 
D

DMUM via AccessMonster.com

Stuart said:
Hello, I have a form that has multiple tabs. On one of the tabs I have a
button that updates a the table behind the forms with a date or deleted
[quoted text clipped - 36 lines]

This line:
Me!sfrmWFLine.Locked = False

is missing a .Form, ie it should read:

Me!sfrmWFLine.Form.Locked = False

I get a run-time error 2465 when I add the Form. The error reads Application-
defined or object-defined error.

Without adding the "FORM" the code runs fine. However, the form is not
unlocked and the particular controls that I also update, do not change. This
code also works fine when the form is first opened. It does not however
seems to modify the form when I use the change button on my form.
 
D

DMUM via AccessMonster.com

DMUM said:
[quoted text clipped - 9 lines]
Me!sfrmWFLine.Form.Locked = False

I get a run-time error 2465 when I add the Form. The error reads Application-
defined or object-defined error.

Without adding the "FORM" the code runs fine. However, the form is not
unlocked and the particular controls that I also update, do not change. This
code also works fine when the form is first opened. It does not however
seems to modify the form when I use the change button on my form.
Just found out something. The code I provided is in 2 places. One is when
the form opens and the other is when the tab (page) is clicked on. When I
open the form, the addition of .form. to the lineitem in the code, gives me
the error I mentioned in the earlier email. The code behind the tabs, do not
error out, but the form still does not unlock/lock

One other thing I noticed is that when the form opens and I use the button to
change the form to lock/unlock, as long as I do not click on any tabs, the
codes does what it is suppose to, however, if I click on any tab before
clicking on the button that lock/unlocks the unlock/unlock does nothing to
the form, yet I get no errors. So it seems my issue has something to do with
the tabs?
 

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