Link to home
Start Free TrialLog in
Avatar of SteveL13
SteveL13Flag for United States of America

asked on

Check a checkbox on main form if record exists in second form

I have a form bound to a table that has a checkbox.  I want this checkbox to be true if any record exists in an unrelated table.  Both tables are "related" via a commonly named field named "JobN".  This field is a number field.  How can I do this?
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

try this in the current event of the form

me.chkbox=(dcount("*","OtherTableName","[jobN]=" & me.JobN)>0)
Avatar of SteveL13

ASKER

Didn't work... here is yuor code with real names plugged in...

Me.chkbxOPsked = (DCount("*", "tblOutpurchase", "[jobN]=" & Me.txtJobN) > 0)
did you check if the current value Me.txtJobN exists in table tblOutpurchase
There is a record in tblOutpurchase that has a JobN value of 67 which is the key number of the JobN field in the main form.
where did you place the code?

post here along with the other codes
Hey, I just put the code in the onload event of the main form and IT WORKED!  Now, one more question...

On the same main form I have a 2nd checkbox.  I want that checkbox to be checked if "chkbxOPdone" is true in the same 2nd table.

??
ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
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
Perfect!  Thank you very much!