set checkbox condition based on compared field values

L

lsb

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

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
 
K

Keith Wilby

lsb said:
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

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

How about making the CodeMatch field a calculated one in your query?

CodeMatch: Iif([CPTA] = [CPTR],-1,0)

Bind your check box to the calculated field.

HTH - Keith.
www.keithwilby.com
 
L

lsb

Thanks, Keith. I apologize but I need a little more clarification
here.

You mention making the CodeMatch field a calculated field in my
query...is that the same as my form? My form is directly tied to the
table I'm using - I didn't design a query

Also - I've never seen the lif(.....) term before - am I to use it in
my code?

How do I "bind" my checkbox to the calculated field CodeMatch?

I've probably been doing these things right along but I don't know the
formal lingo so your response is probably what I'm looking for and I
don't have enough experience doing this to know any better!

Thanks,
LB


Keith said:
lsb said:
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

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

How about making the CodeMatch field a calculated one in your query?

CodeMatch: Iif([CPTA] = [CPTR],-1,0)

Bind your check box to the calculated field.

HTH - Keith.
www.keithwilby.com
 
K

Keith Wilby

lsb said:
Thanks, Keith. I apologize but I need a little more clarification
here.

You mention making the CodeMatch field a calculated field in my
query...is that the same as my form? My form is directly tied to the
table I'm using - I didn't design a query

Also - I've never seen the lif(.....) term before - am I to use it in
my code?

How do I "bind" my checkbox to the calculated field CodeMatch?

I've probably been doing these things right along but I don't know the
formal lingo so your response is probably what I'm looking for and I
don't have enough experience doing this to know any better!

"Iif" means "in-line IF". It's a method of evaluating an IF statement
(search the help for how it works). If you use this method then you will
need to create a query to bind your form to instead of binding it directly
to your table as you have now. The other solution provided requires some
code, this requires none. If you create a query based on your table and
include all of the fields, you can then use

CodeMatch: Iif([CPTA] = [CPTR],-1,0)

as a calculated field (again, search the help for more info). You can then
bind your check box to this calculated field ("bind" means use it as your
check box's data source).

Regards,
Keith.
 

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