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  

Totals not working



 
 
Thread Tools Display Modes
  #1  
Old February 8th, 2010, 07:48 PM posted to microsoft.public.access.forms
iamnu
external usenet poster
 
Posts: 99
Default Totals not working

In tblRecipes I have a Field as follows:
TotalCount: Nz(DCount("*","tblRecipeCategories","RecipeID = " &
[RecipeID]))

This works fined until I "Filter" the records with the Procedure
below, when TotalCount gives me "#Error".
How do I make TotalCount work with the following Procedure?
Thanks, Bernie

Private Sub cboShowCategory_AfterUpdate()
Dim strSQL As String
strSQL = "SELECT DISTINCTROW tblRecipes.* FROM tblRecipes " & _
"INNER JOIN tblRecipeCategories ON " & _
"tblRecipes.RecipeID = tblRecipeCategories.RecipeID " & _
"WHERE tblRecipeCategories.CategoryID = " & Me.cboShowCategory
& ";" 'this code works if the value is a number (like CategoryID)
Me.RecordSource = strSQL
End Sub
  #2  
Old February 10th, 2010, 03:41 PM posted to microsoft.public.access.forms
Daryl S[_2_]
external usenet poster
 
Posts: 881
Default Totals not working

Iamnu -

The Nz function is missing all of the parameters. Try this:

TotalCount: Nz(DCount("*","tblRecipeCategories","RecipeID = " &
[RecipeID]),0)

--
Daryl S


"iamnu" wrote:

In tblRecipes I have a Field as follows:
TotalCount: Nz(DCount("*","tblRecipeCategories","RecipeID = " &
[RecipeID]))

This works fined until I "Filter" the records with the Procedure
below, when TotalCount gives me "#Error".
How do I make TotalCount work with the following Procedure?
Thanks, Bernie

Private Sub cboShowCategory_AfterUpdate()
Dim strSQL As String
strSQL = "SELECT DISTINCTROW tblRecipes.* FROM tblRecipes " & _
"INNER JOIN tblRecipeCategories ON " & _
"tblRecipes.RecipeID = tblRecipeCategories.RecipeID " & _
"WHERE tblRecipeCategories.CategoryID = " & Me.cboShowCategory
& ";" 'this code works if the value is a number (like CategoryID)
Me.RecordSource = strSQL
End Sub
.

 




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 12:20 AM.


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