Access2000: Problem with enabling/disabling controls in subform

A

Arvi Laanemets

Hi

1. I have a multipage unbound form fmMain;
2. On one of pages is a subform control sfDeviceGroups with form
fmDeviceGroups as source. Form fmDeviceGroup is used to filter underlying
form;
3. On form fmDeviceGroup is a subform control sfDevices with form fmDevices
as source. And a combo box to select device group - only devices from
selected group are available in subform;
4. On form fmDevices is a combo to select a device and navigate to according
record, a lot of various controls displaying data from table tblDevices (by
default all those controls except combo are disabled), a subform control
sfTransactions with contignous form fmTransactions as source (by default all
controls disabled) which does display all tranactions for selected device,
and an enabled (unless it's a new record) check box to unlock/lock all data
controls in forms fmDevices and fmTransactions.

When check box is checked, all data controls are enabled (Generally - there
are some of them behaving differently for different device groups. And there
are some controls always hidden), so user can change them. When check box is
checked again, or when user moves to another record, all previously unlocked
data controls on both forms are locked again.

It works fine, until user doesn't activate any control in fmTransactions.
When some control in fmTransactions is activated, it doesn't lost focus even
when any control in fmDevices is activated afterwards - and whenever user
locks data or moves to another record, an error message "You can't disable a
control when it has a focus" is displayed until the session is ended.

I think the problem is, that unlike fmDevices, where combo and check box
remain unlocked, on fmTransactions no control remains enabled and visible.
And I can't simply disable whole subform too, because user has to be able to
scroll on subform to view all records.


My question is, how to make all subform controls to lose focus when controls
are locked.
Thanks in advance!
--
Arvi Laanemets
( My real mail address: arvi.laanemets<at>tarkon.ee )



PS. There are 2 events from fmDevices, taking care of locking/unlocking:

Private Sub Form_Current()
Me.txtRegDate.Enabled = (Nz(Me.txtDeviceID, "") = "")
Me.comRegisterDevice.Visible = (Nz(Me.txtDeviceID, "") = "")
Me.txtProducer.Enabled = Nz(Me.txtDeviceID, "") <> "" And Not
Me.chkRecLock
Me.txtMark.Enabled = Nz(Me.txtDeviceID, "") <> "" And Not Me.chkRecLock
Me.txtModel.Enabled = Nz(Me.txtDeviceID, "") <> "" And Not Me.chkRecLock
Me.txtSN.Enabled = Nz(Me.txtDeviceID, "") <> "" And Not Me.chkRecLock
Me.lblF1.Caption = Nz(Me.txtF1Label, "")
Me.txtF1.Visible = Nz(Me.txtF1Label, "") <> ""
Me.txtF1.Enabled = Nz(Me.txtDeviceID, "") <> "" And Not Me.chkRecLock
Me.lblF2.Caption = Nz(Me.txtF2Label, "")
Me.txtF2.Visible = Nz(Me.txtF2Label, "") <> ""
Me.txtF2.Enabled = Nz(Me.txtDeviceID, "") <> "" And Not Me.chkRecLock
Me.lblF3.Caption = Nz(Me.txtF3Label, "")
Me.txtF3.Visible = Nz(Me.txtF3Label, "") <> ""
Me.txtF3.Enabled = Nz(Me.txtDeviceID, "") <> "" And Not Me.chkRecLock
Me.txtFixIP.Visible = Me.chkHasIP
Me.lblFixIP.Visible = Me.chkHasIP
Me.txtFixIP.Enabled = Nz(Me.txtDeviceID, "") <> "" And Not Me.chkRecLock
Me.txtProvider.Enabled = Nz(Me.txtDeviceID, "") <> "" And Not
Me.chkRecLock
Me.txtInvoiceNum.Enabled = Nz(Me.txtDeviceID, "") <> "" And Not
Me.chkRecLock
Me.txtInvoiceDate.Enabled = Nz(Me.txtDeviceID, "") <> "" And Not
Me.chkRecLock
Me.txtQuaranteeDate.Enabled = Nz(Me.txtDeviceID, "") <> "" And Not
Me.chkRecLock
Me.txtRemarks.Enabled = Nz(Me.txtDeviceID, "") <> "" And Not
Me.chkRecLock
Forms!fmMain!sfDeviceGroups!sfDevices!sfITTransactions!txtTransactDate.Enabled
= Nz(Me.txtDeviceID, "") <> "" And Not Me.chkRecLock
Forms!fmMain!sfDeviceGroups!sfDevices!sfITTransactions!cbbAccount.Enabled
= Nz(Me.txtDeviceID, "") <> "" And Not Me.chkRecLock
Forms!fmMain!sfDeviceGroups!sfDevices!sfITTransactions!cbbTabN.Enabled =
Nz(Me.txtDeviceID, "") <> "" And Not Me.chkRecLock
Forms!fmMain!sfDeviceGroups!sfDevices!sfITTransactions!cbbOwnerID.Enabled
= Nz(Me.txtDeviceID, "") <> "" And Not Me.chkRecLock
Forms!fmMain!sfDeviceGroups!sfDevices!sfITTransactions!chkIsFund.Enabled
= Nz(Me.txtDeviceID, "") <> "" And Not Me.chkRecLock
Me.chkRecLock = (Nz(Me.txtDeviceID, "") <> "")
Me.lblRecLock.Caption = IIf(Me.chkRecLock, "Unlock Record", "Lock
Record")
Me.chkRecLock.Enabled = (Nz(Me.txtDeviceID, "") <> "")
Me.cbbSelectDevice = Me.txtDeviceID
End Sub

Private Sub chkRecLock_Click()
Me.txtProducer.Enabled = Nz(Me.txtDeviceID, "") <> "" And Not
Me.chkRecLock
Me.txtMark.Enabled = Nz(Me.txtDeviceID, "") <> "" And Not Me.chkRecLock
Me.txtModel.Enabled = Nz(Me.txtDeviceID, "") <> "" And Not Me.chkRecLock
Me.txtSN.Enabled = Nz(Me.txtDeviceID, "") <> "" And Not chkRecLock
Me.txtF1.Enabled = Nz(Me.txtDeviceID, "") <> "" And Not chkRecLock
Me.txtF2.Enabled = Nz(Me.txtDeviceID, "") <> "" And Not chkRecLock
Me.txtF3.Enabled = Nz(Me.txtDeviceID, "") <> "" And Not chkRecLock
Me.txtFixIP.Enabled = Nz(Me.txtDeviceID, "") <> "" And Not Me.chkRecLock
Me.txtProvider.Enabled = Nz(Me.txtDeviceID, "") <> "" And Not
Me.chkRecLock
Me.txtInvoiceNum.Enabled = Nz(Me.txtDeviceID, "") <> "" And Not
chkRecLock
Me.txtInvoiceDate.Enabled = Nz(Me.txtDeviceID, "") <> "" And Not
chkRecLock
Me.txtQuaranteeDate.Enabled = Nz(Me.txtDeviceID, "") <> "" And Not
chkRecLock
Me.txtRemarks.Enabled = Nz(Me.txtDeviceID, "") <> "" And Not chkRecLock
Forms!fmMain!sfDeviceGroups!sfDevices!sfITTransactions!txtTransactDate.Enabled
= Nz(Me.txtDeviceID, "") <> "" And Not Me.chkRecLock
Forms!fmMain!sfDeviceGroups!sfDevices!sfITTransactions!cbbAccount.Enabled
= Nz(Me.txtDeviceID, "") <> "" And Not Me.chkRecLock
Forms!fmMain!sfDeviceGroups!sfDevices!sfITTransactions!cbbTabN.Enabled =
Nz(Me.txtDeviceID, "") <> "" And Not Me.chkRecLock
Forms!fmMain!sfDeviceGroups!sfDevices!sfITTransactions!cbbOwnerID.Enabled
= Nz(Me.txtDeviceID, "") <> "" And Not Me.chkRecLock
Forms!fmMain!sfDeviceGroups!sfDevices!sfITTransactions!chkIsFund.Enabled
= Nz(Me.txtDeviceID, "") <> "" And Not Me.chkRecLock
Me.lblRecLock.Caption = IIf(Me.chkRecLock, "Unlock Record", "Lock
Record")
End Sub
 
A

Arvi Laanemets

Hi again

Forget it - I did find a solution (a dummy unbound field of 0 width on
subform), and in both events the focus is set to this dummy field.
 

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