Combo Box Locked and Disabled but still clickable (1 Viewer)

DBApprentice

On Error GoTo AWF *****:
Local time
Today, 20:07
Joined
Dec 24, 2018
Messages
150
Guys,

I have a combobox that is locked and disabled along with the rest of the controls but I click on it and even open the drop-down list whilst I won´t be able to select anything inside it.

The controls are disabled and locked from their property sheet, not in any event from the form, but I tested it on a button that locks and disables the controls. When I use the button the combobox is not clickable anymore.

Any idea for this strange behavior?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 16:07
Joined
Oct 29, 2018
Messages
21,358
Hi. Can we see a sample copy of the problem to properly evaluate it?
 

Micron

AWF VIP
Local time
Today, 19:07
Joined
Oct 20, 2018
Messages
3,476
You're describing a locked and enabled situation. Are you sure you have both locked - yes and enabled - no? If so, my guess is the control is corrupted. Happens now and again.
 

DBApprentice

On Error GoTo AWF *****:
Local time
Today, 20:07
Joined
Dec 24, 2018
Messages
150
You're describing a locked and enabled situation. Are you sure you have both locked - yes and enabled - no? If so, my guess is the control is corrupted. Happens now and again.

Any idea on how to fix that?
 

CJ_London

Super Moderator
Staff member
Local time
Today, 23:07
Joined
Feb 19, 2013
Messages
16,553
Any idea on how to fix that?
at its most basic, and you are sure it is not a coding issue, compact and repair.

If that doesn't work, delete the control, save and close the form, compact and repair again, reopen the form and recreate the control.

If that still doesn't work, delete the whole form, compact and repair then recreate the form from scratch

and if still not working, sounds like you have an issue with the code. If you are convinced that is not the case, create a new, blank database, copy all objects except the form, then recreate the form from scratch,
 

DBApprentice

On Error GoTo AWF *****:
Local time
Today, 20:07
Joined
Dec 24, 2018
Messages
150
at its most basic, and you are sure it is not a coding issue, compact and repair.

If that doesn't work, delete the control, save and close the form, compact and repair again, reopen the form and recreate the control.

If that still doesn't work, delete the whole form, compact and repair then recreate the form from scratch

and if still not working, sounds like you have an issue with the code. If you are convinced that is not the case, create a new, blank database, copy all objects except the form, then recreate the form from scratch,



Thanks CJ! I will work on that. Seems this file is building up a lot of issues against me lately.

Now I have just noticed another combobox is behaving oddly: if disable it and enables it becomes locked and won’t work unless I remove it’a events and recode again....

I will let you know once I make a fresh start over for the third now!


Enviado do meu iPhone usando Tapatalk
 

Micron

AWF VIP
Local time
Today, 19:07
Joined
Oct 20, 2018
Messages
3,476
or you could post the problem db. If it's not a coding issue (you might have involved a condition that is changing on you) then I would also suspect corruption of the control if one combo was involved, but two? I would certainly keep the form handy if you start over.
 

DBApprentice

On Error GoTo AWF *****:
Local time
Today, 20:07
Joined
Dec 24, 2018
Messages
150
or you could post the problem db.
...

The form is attached, I have removed a lot of code from the original form as per Isladogs' and JHB's advice.

  • The comboboxes with problems are on frmCardObservations, which is an editable form.
  • cboGoTo is the one being "locked" if I change it´s LOCKED and ENABLED property when I click on EDIT button and later click on LOCK button.
  • cboBehaviorFK and cboBehaviorIssuesFK are the two comboboxes that are being clickable when the form opens. Originally I had a afterupdate event associated with these two controls but then i decided to test the conditional formating to have less code being triggered on events.
Any help is very much appreciated.

My main goal is to have a form to load locked so that the user won´t be changing anything by mistake, if he wants to change something he will click on the EDIT button, the LOCK button will be later called SAVED and will have some SELECT CASE to deal with constraints.
 

Attachments

  • SOC Manager DB Problem.zip
    353.3 KB · Views: 54

CJ_London

Super Moderator
Staff member
Local time
Today, 23:07
Joined
Feb 19, 2013
Messages
16,553
from what I can see, your lock and edit buttons do not even look at the goto combo - they only look at controls in the tab control and form footer
 

CJ_London

Super Moderator
Staff member
Local time
Today, 23:07
Joined
Feb 19, 2013
Messages
16,553
there does seem something wrong - I deleted the original combo and created a new one with the same properties and that behaves as expected
 

JHB

Have been here a while
Local time
Tomorrow, 00:07
Joined
Jun 17, 2012
Messages
7,732
I've loaded your database, I can't see anything wrong with the cboGoTo, only that it doesn't show any value, but it is because you clear it the AfterUpDate event for cboGoTo.
Code:
Me.cboGoTo.Value = Null 'Empty the Combo box
When you choose a value from the list it brings you to that record.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 23:07
Joined
Feb 19, 2013
Messages
16,553
Cbogoto is a red herring - issue is with the behaviour cbo’s Highlighted in red. I made the same mistake!
 

DBApprentice

On Error GoTo AWF *****:
Local time
Today, 20:07
Joined
Dec 24, 2018
Messages
150
I've loaded your database, I can't see anything wrong with the cboGoTo, only that it doesn't show any value, but it is because you clear it the AfterUpDate event for cboGoTo.
Code:
Me.cboGoTo.Value = Null 'Empty the Combo box
When you choose a value from the list it brings you to that record.

That was intentional, once the code on the cboGoto after update event loads the record to the form then I don´t want cboGoto to display the card number since it is already being displayed on the lblHeader on the top.

I have done some testing and commented this part of the code and also tested changing the NULL to "":
Code:
Me.cboGoTo.Value = Null 'Empty the Combo box

The "LOCKED" effect is not happening anymore immediately after I click on the LOCK button. It is happening when close and open this form again...
 

DBApprentice

On Error GoTo AWF *****:
Local time
Today, 20:07
Joined
Dec 24, 2018
Messages
150
Cbogoto is a red herring - issue is with the behaviour cbo’s Highlighted in red. I made the same mistake!

In that form I have got 3 issues actually:

  • cboGoTo that has the "locked" effect after being disabled and enabled again.
  • cboBehaviorFK and cboBehaviorIssuesFK that remains clickable even after they are locked and disabled.
 

DBApprentice

On Error GoTo AWF *****:
Local time
Today, 20:07
Joined
Dec 24, 2018
Messages
150
I changed the code from the button on the main form that opens the frmCardObservation to this:

Code:
DoCmd.OpenForm "frmCardObservation", acNormal, , , acFormEdit

The cboGoTo odd behavior is not locking itself after closing and reopening the form or clicking on editing and locking again. I guess strike that off my issue list.

But I still can´t figure out what is going on with the other two comboboxes:

cboBehaviorFK and cboBehaviorIssuesFK that remains clickable even after they are locked and disabled.
 

isladogs

MVP / VIP
Local time
Today, 23:07
Joined
Jan 14, 2017
Messages
18,186
But I still can´t figure out what is going on with the other two comboboxes:

cboBehaviorFK and cboBehaviorIssuesFK that remains clickable even after they are locked and disabled.

Your conditional formatting is preventing the code working properly
If you remove it, the controls behave as expected.

If you really need both CF & the lock/edit toggle, you may be able to achieve it by applying & removing CF using VBA instead of the wizard (not tested)
 

DBApprentice

On Error GoTo AWF *****:
Local time
Today, 20:07
Joined
Dec 24, 2018
Messages
150
Your conditional formatting is preventing the code working properly
If you remove it, the controls behave as expected.

If you really need both CF & the lock/edit toggle, you may be able to achieve it by applying & removing CF using VBA instead of the wizard (not tested)

My dear Colin, as usual, you were right! :)

The moment I removed the CF both controls became locked. I will test the theory proposed.

Thanks for the help!
 

DBApprentice

On Error GoTo AWF *****:
Local time
Today, 20:07
Joined
Dec 24, 2018
Messages
150
...
If you really need both CF & the lock/edit toggle, you may be able to achieve it by applying & removing CF using VBA instead of the wizard (not tested)

Colin,

I have changed the Form_Current event to this to mimic the removed the CF:

Code:
Private Sub Form_Current()
Me.lblHeader.Caption = "SAFETY OBSERVATION CARD: " & Me.txtCardNumber
Me.cboBehaviorIssuesFK.RowSource = " SELECT tblBehaviorsIssues.BehaviorIssueID, tblBehaviors.BehaviorID, tblBehaviorsIssues.IssueBehavior " & _
                                                                    "FROM tblBehaviors INNER JOIN tblBehaviorsIssues " & _
                                                                    "ON tblBehaviors.BehaviorID = tblBehaviorsIssues.BehavioID " & _
                                                                    "WHERE (((tblBehaviors.BehaviorID)=[Forms]![frmCardObservation]![cboBehaviorFK])) " & _
                                                                    "ORDER BY tblBehaviorsIssues.IssueBehavior; "
 Select Case Me.cboBehaviorFK.Value
        Case 1
            Me.cboBehaviorFK.BackColor = RGB(152, 251, 152)
            Me.cboBehaviorFK.ForeColor = RGB(25, 25, 112)
            Me.lblBehaviorIssue.Caption = "Observed Behavior"
            Me.cboBehaviorIssuesFK.BackColor = RGB(152, 251, 152)
            Me.cboBehaviorIssuesFK.ForeColor = RGB(25, 25, 112)
        Case 2
            Me.cboBehaviorFK.BackColor = RGB(205, 92, 92)
            Me.cboBehaviorFK.ForeColor = RGB(255, 255, 0)
            Me.lblBehaviorIssue.Caption = "Observed Issue "
            Me.cboBehaviorIssuesFK.BackColor = RGB(205, 92, 92)
            Me.cboBehaviorIssuesFK.ForeColor = RGB(255, 255, 0)
        Case Else
            Me.lblBehaviorIssue.Caption = "Observed Issue / Desired Behavior"
            Me.cboBehaviorIssuesFK.BackColor = vbWhite
            Me.cboBehaviorIssuesFK.ForeColor = RGB(25, 25, 112)
    End Select
End Sub

Only cboBehaviorIssuesFK was misbehaving so I added this:

Code:
Me.cboBehaviorIssuesFK.Locked = True
Me.cboBehaviorIssuesFK.Enabled = False

And now it is behaving as expected.

My concern now is: placing that code on the Current event will cause any downside?
 

isladogs

MVP / VIP
Local time
Today, 23:07
Joined
Jan 14, 2017
Messages
18,186
The issue with placing code in the Form_Current event is that it runs whenever anything changes - in other words repeatedly.
This could potentially cause a performance issue....

Suggest you make the code into a form procedure (so it can be reused) and just call it from the two buttons (Lock & Edit) and from Form_Load ... or when necessary
 

Users who are viewing this thread

Top Bottom