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?
SteveL13Asked:
Who is Participating?
 
Rey Obrero (Capricorn1)Connect With a Mentor Commented:
me.chk2=dlookup("chkbxOpDone","tblOutpurchase", "[jobN]=" & Me.txtJobN)
0
 
Rey Obrero (Capricorn1)Commented:
try this in the current event of the form

me.chkbox=(dcount("*","OtherTableName","[jobN]=" & me.JobN)>0)
0
 
SteveL13Author Commented:
Didn't work... here is yuor code with real names plugged in...

Me.chkbxOPsked = (DCount("*", "tblOutpurchase", "[jobN]=" & Me.txtJobN) > 0)
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
Rey Obrero (Capricorn1)Commented:
did you check if the current value Me.txtJobN exists in table tblOutpurchase
0
 
SteveL13Author Commented:
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.
0
 
Rey Obrero (Capricorn1)Commented:
where did you place the code?

post here along with the other codes
0
 
SteveL13Author Commented:
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.

??
0
 
SteveL13Author Commented:
Perfect!  Thank you very much!
0
All Courses

From novice to tech pro — start learning today.