Fill checkbox automatically

roxys

New member
Local time
Today, 10:52
Joined
Aug 30, 2009
Messages
4
Hello,

I want to let access fill in a checkbox automatically based on the value of another field in the same table.

I have a student course registration system in access, and I have a table of Marks that have a mark field, diploma field and the student_id, that I enter the marks that the student gets for an exam. The diploma field is a checkbox.

And I want to let the diploma field checkbox be filled in automatically when I enter the mark field, and if the mark field value is more than 5.5.

Can anyone help me with that?

Thanks
 
In the OnChange event of your first field, put the following;
Code:
If Me.YourFieldName => [B]X[/B] Then [COLOR="Green"]'Were [B]X[/B] is the value you wish to check for[/COLOR]
     Me.CheckBoxName = -1
Else
     Me.CheckBoxName = 0
End If

Check boxes store "Checked" as -1 (true) and "Unchecked" as 0 (false)
 
Last edited:
In the OnChange event of your first field, put the following;
Code:
If Me.YourFieldName => [B]X[/B] Then [COLOR=green]'Were [B]X[/B] is the value you wish to check for[/COLOR]
     Me.CheckBoxName = -1
Else
     Me.CheckBoxName = 0
End If

Check boxes store "Checked" as -1 (true) and "Unchecked" as 0 (false)

Hi, thanks for your answer.

I used the code, but I used in the OnEnter event, because on the OnChange it would only check the checkbox when you change the value.

But the OnEnter it would check it when I enter the value.

But I have a question.
How can I put it that as I enter the value the checkbox check immediately, so that you see it when it checked.

Because now it check the checkbox, but when you go to the next record it change it. So when you go to the previous you see in the matter of fact that the checkbox is checked.
 
Hi, thanks for your answer.

I used the code, but I used in the OnEnter event, because on the OnChange it would only check the checkbox when you change the value.

But the OnEnter it would check it when I enter the value.

But I have a question.
How can I put it that as I enter the value the checkbox check immediately, so that you see it when it checked.

Because now it check the checkbox, but when you go to the next record it change it. So when you go to the previous you see in the matter of fact that the checkbox is checked.


I have already solved the problem.
I had to put it on the OnClick event.

Thanks for your help. I appreciate it.
 
note that you can do stuff like this in 2 ways normally

a PUSH method, which involves testing the value in the update and current events of the form, or of various controls, and pushing the value into the target field. (which is what you have)

a PULL method, where the control source of the target field is bound to a suitable function or calculation that therefore automatically pulls in the correct value if the source changes.
 

Users who are viewing this thread

Back
Top Bottom