A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Showing a value from a query on a form



 
 
Thread Tools Display Modes
  #11  
Old October 23rd, 2009, 06:38 AM posted to microsoft.public.access.forms
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Showing a value from a query on a form

On Thu, 22 Oct 2009 20:59:01 -0700, scottyboyb
wrote:

The field I am trying to count records for is an autonumber primary key of
the "Pledges" table which holds the data about the pledges made and paid by
contributors (different table). The field is called PledgeID. Datatype
autonumber.


Well, if you are just counting records, it's not essential to count the
Primary Key field: you could use =DCount("*"...) to count records. Should give
the same results though.

The form control that provides the form's data criteria is on a form called
"Campaigns" and the form control is a text box that gets it's data from a
field whose datatype is text in a table called "Donation Campaign Setup". The
text box's control source is a field in "Donation Campaign Setup" called
"CampaignName" and the text box's name is CampaignNameField.

The control for the DCount expression is a text box on the same form
"Campaigns" with the name "Total Number of Pledges".

Is there anythng else you need to know?


I believe so: which field in "Pledges" are you trying to match to the value in
CampaignNameField? Assuming that it's Campaign and that it's a Text field,
then

=DCount("[PledgeID]", "Pledges", "[Campaign] = '" &
Forms!Campaigns![CampaignNameField] & "'")

That's two possibly incorrect assumptions there (fieldname and datatype) but
hopefully you can adapt...

The trick is that the third argument to any domain function needs to be a SQL
WHERE clause without the word WHE in my suggestion,

[Campaign] = 'Halloween Party'

--

John W. Vinson [MVP]
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 04:48 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.