Link to home
Start Free TrialLog in
Avatar of gigifarrow
gigifarrow

asked on

Trying to get check mark to disable when click and turn black, Once user makes mistake click to undo

Hello,

Experts. I have a database when you check it. It disables and turns black. Then I have a button that if that is a mistake you click on it to undo. but they both are not working because of the set focus is on the field to undo here is my code and here is the database.

To disable and turn black  I have after Update when you click the check mark:

Private Sub Defuel_AfterUpdate()
Me.Defuel.SetFocus
  If Me.Defuel.Value = True Then
    Me.Defuel.Enabled = False
    Me.Label4.BackColor = FFF200
  End If
End Sub

To reset I have on Click of a button :

 Private Sub Command221_Click()
  Me.Induction.Enabled = True
  Me.Label4.BackColor = vbWhite
  Me.Refresh
End Sub
bingo3.accdb
Avatar of mbizup
mbizup
Flag of Kazakhstan image

Set the focus to some other control before disabling it:


Private Sub Defuel_AfterUpdate()
Me.Defuel.SetFocus
  If Me.Defuel.Value = True Then
   Me.SomeOtherControl.SetFocus
    Me.Defuel.Enabled = False
    Me.Label4.BackColor = FFF200
  End If
End Sub
Avatar of gigifarrow
gigifarrow

ASKER

Okay thanks for your help
I did change it how you said so it looks like it is below.

1.when I hit reset it enables. But when I go to check it again. I get an error #2110 Can not set focus to Defuel .

 2. Also when I click the checks ony one turns black the others dont they just disable.


This is what Im doing on clicking the check boxes:

Private Sub Induction_AfterUpdate()
Me.Induction.SetFocus
  If Me.Induction.Value = True Then
    Me.Defuel.SetFocus
    Me.Induction.Enabled = False
    Me.Label4.BackColor = FFF200
  End If
  End Sub


Private Sub Defuel_AfterUpdate()
Me.Defuel.SetFocus
  If Me.Defuel.Value = True Then
  Me.Turret_ull.SetFocus
    Me.Defuel.Enabled = False
    Me.Label4.BackColor = FFF200
  End If
End Sub
This is what Im doing on reset:


Private Sub Command229_Click()
    Me.Induction.Enabled = True
    Me.Label7.BackColor = vbWhite
    Me.Refresh
End Sub
If Defuel is disabled, then you cannot set focus to it.

When doing things like this you have to control your code very tightly.

Consider moving all the "Set Properties" code to one sub, then make calls to this sub, from the needed events....

JeffCoachman
I can't open your database at this time, but regarding the label color,  you may need to use a label that is not attached' to your check box for this kind of effect.
ASKER CERTIFIED SOLUTION
Avatar of Jeffrey Coachman
Jeffrey Coachman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
gigifarrow,

Not sure I follow your "Reset" logic...?

All your "reset" button does is enable the control again,  and set the color to white.
A true "reset" would check/un-check the control as well, because AFAICT, the properties are based on the control being true or false.
I can't see why you would want to reset the properties and not uncheck the control....
Am I missing something?

Also not sure why the refresh is needed either...
When you open your form, would all the checkboxes be false or are some already checked?  If the latter, would the checked ones need to be disabled and have a black background?
Thanks for all the help again experts. The reason for the check and uncheck


is if the user makes a mistake.
The user is going back and forth to each record everyday to add what they have done to the vehicle.

If they check it we dont wont them to accidentally uncheck it because the checks are a total of precentages.  If it is accidentally unchecked or checked all calculations will be off.

When they finish each step they want it to be disabled and to change you have to reset it.  They dont want them to go back and change it unless it is a mistake. When everything is black they know it is 100% finished

So if you reset it and uncheck we know it was done on purpose because that step had not been covered or they just accidentally hit it. I dont know the code to remove the check. I thought I would just enable and be able to uncheck it.

I hope that sounds clearer.


I am not an expert and there is probably a  better way that I could have done it.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You accepted:
https://www.experts-exchange.com/questions/27977783/Trying-to-get-check-mark-to-disable-when-click-and-turn-black-Once-user-makes-mistake-click-to-undo.html?anchorAnswerId=38721736#a38721736
That was just me posting the code for other experts (who may not have been able to open the db.

Please click the request Attention Link and have that post un-accepted.

Jeff