[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 348
  • Last Modified:

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?
0
Scotto123
Asked:
Scotto123
  • 3
  • 2
1 Solution
 
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
 
Scotto123Author Commented:
I see your point Peter.  So if I bound the control to the table, how would the code look?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
peter57rCommented:
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
 
Jeffrey CoachmanCommented:
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

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now