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
Microsoft AccessProgramming Languages-OtherVisual Basic Classic

Avatar of undefined
Last Comment
Jeffrey Coachman

8/22/2022 - Mon
mbizup

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
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
Jeffrey Coachman

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
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
mbizup

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
Jeffrey Coachman

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Jeffrey Coachman

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...
IrogSinta

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?
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
gigifarrow

ASKER
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
IrogSinta

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
Hamed Nasr

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Jeffrey Coachman

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