• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 398
  • Last Modified:

DCount in Bound Field

I am having trouble using DCount in a bound text field. Is this possible? I can use the following syntax to get the result in an unbound control in a query, but would like to place the results in a bound field in a table. Thanks.

Sets: DCount("SetsRepID","tblSetsDetail","SetsRepID = " & [StrID])
0
skennelly
Asked:
skennelly
  • 3
1 Solution
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
"in a bound text field. "
You mean on a Form ?

You can do this ... set the Control Source of an *unbound* Text box to:

=DCount("SetsRepID","tblSetsDetail","[SetsRepID] = " & [StrID])

Not completely sure what you   mean ...

mx
0
 
Jim Dettman (Microsoft MVP/ EE MVE)PresidentCommented:
<<I am having trouble using DCount in a bound text field. Is this possible?>>

 No it's not possible.  You'll need to set the control (or field that the control is bound to) in code from somewhere else.

JimD.
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
You can also do this ... to set a Field in your table, using the Form Before Update event.

Private Sub Form_BeforeUpdate (Cancel As Integer)

me![YourFieldNameInTheTable] = DCount("SetsRepID","tblSetsDetail","SetsRepID = " & [StrID])

End Sub

mx
0
 
skennellyAuthor Commented:
Got it, thanks.
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
You are welcome ...

mx
0

Featured Post

Microsoft Certification Exam 74-409

VeeamĀ® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

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