Solved

DCount in Bound Field

Posted on 2011-03-09
5
331 Views
Last Modified: 2012-06-27
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
Comment
Question by:skennelly
  • 3
5 Comments
 
LVL 75
ID: 35087202
"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
 
LVL 57
ID: 35087222
<<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
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Access MVP) earned 125 total points
ID: 35087253
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
 

Author Closing Comment

by:skennelly
ID: 35087621
Got it, thanks.
0
 
LVL 75
ID: 35087640
You are welcome ...

mx
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now