set checkbox condition based on comparing two fields

G

Guest

Need to compare the value of two numeric fields and automatically have
a checkbox indicate whether the fields values are equal (Checkbox
checked) or not (checkbox unchecked)

I'm not a programmer - but have had great success utilizing codes I've
found on this forum to make simple things work.

The fields I'm comparing are numeric - standard data entry fields.

Field names are CPTA and CPTR and the checkbox name is CodeMatch

What code would I use for this?

Do I put the code on on the current page or tie it to the second field
I'm trying to compare or to the check box itself.

Any assistance would be greatly appreciated.

Thanks,
LB
 
G

Guest

If the values in the boxes do not change once the form is open, I believe the
code would be simple.

Put the following code in the form's OnLoad event:

If Me.CPTA = Me.CPTR Then
Me.CodeMatch = True
Else
Me.CodeMatch = False
End If


If the values might change while the form is open, you can still accomplish
this, but it's a little more involved. Let me know if this is the case and
I'll explain it.

Hope that helps. Good luck

-ndalton
 
G

Guest

The boxes will change since they start empty and a data entry person is
typing in the codes. Once they leave that field I need the check box to
indicate whether the codes match or not.

Many thanks for responding!
LB
 
G

Guest

Okay. I think all you need to do is put that same code in each of the code's
text field's OnUpdate event. This will cause the form to check whether they
are equal every time either one of them is changed.

-ndalton
 
G

Guest

Do you mean OnEnter? or AfterUpdate? I don't see and OnUpdate event in the
properties sheet for the text boxes.... This is just about there now.

Thanks!
 

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