Count Related Records in other Table and if >1 change control

I want to populate a control (not bound) on my continuous form when there are records in a different table.  

I've gotten this far but need help making the control change.  
DLookup("Count(*)", "[BoardComments]", "[BoardID] = " & Me.BoardID)

Something like this?
If
DLookup("Count(*)", "[BoardComments]", "[BoardID] = " & Me.BoardID)>0
Then
me.CommentsYes=1
Else
me.CommentsYes=0
End If

Doesn't like that.  Suggestions?
Scotto123Asked:
Who is Participating?
 
peter57rConnect With a Mentor Commented:
If you have bound controls then the code you posted should work. I assume the code would go in the form current event, so you would only get the result for a record when you moved to that record.

If you want to see the results for all records as soon as you open the form,  then you would have to run an update query to set the 1's and 0's  on your table before opening the form, or maybe in the form open event.  Then you would not need any further code in the form for this purpose.
0
 
peter57rCommented:
If you use an unbound control, every record will show the same value as derived from the current record.  You cannot show different values in different records.
0
 
Scotto123Author Commented:
That's why I'm using the Dlookup to lookup the BoardID from the current record.  
Still won't work?
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

 
Scotto123Author Commented:
I see your point Peter.  So if I bound the control to the table, how would the code look?
0
 
Jeffrey CoachmanMIS LiasonCommented:
Examine Pete's suggestion first.

For strictly informational purposes, here is something similar I did for another similar question
(If a Customer had Orders)
Database34.mdb
0
 
Scotto123Author Commented:
I will work on this when I get back to work on 9/3.  I will take both solutions into consideration.  Thank you.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.