473,670 Members | 2,327 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why would a DCount of FieldName in saved query return a number greater than number of rows in qry?

MLH
?dcount("[OwnerFName]","qryOwnrsDueI TSwMissingAddr" )
when run in the immediate window return a number greater
than the number of rows that display when the saved query
is run - opening in the database window?

I consistently see 2 rows in qryOwnrsDueITSw MissingAddr
opening with a dbl-clik. Yet

?dcount("[OwnerFName]","qryOwnrsDueI TSwMissingAddr" )
returns 3 and

?dcount("[VehicleJobID]","qryOwnrsDueI TSwMissingAddr" )
returns 4.
Jan 12 '06 #1
7 1837
It's a little hard to guess the reason when we have no idea what is in
qryOwnrsDueITSw MissingAddr, whether parameters function calls, or de-duping
could cause different results every time it is run.

One possibility is that you have a corrupted index. Try:
Tools | Database Utilites | Compact/Repair

If that does not work post the SQL statement for the query.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"MLH" <CR**@NorthStat e.net> wrote in message
news:1h******** *************** *********@4ax.c om...
?dcount("[OwnerFName]","qryOwnrsDueI TSwMissingAddr" )
when run in the immediate window return a number greater
than the number of rows that display when the saved query
is run - opening in the database window?

I consistently see 2 rows in qryOwnrsDueITSw MissingAddr
opening with a dbl-clik. Yet

?dcount("[OwnerFName]","qryOwnrsDueI TSwMissingAddr" )
returns 3 and

?dcount("[VehicleJobID]","qryOwnrsDueI TSwMissingAddr" )
returns 4.

Jan 12 '06 #2
MLH
On Thu, 12 Jan 2006 22:38:16 +0800, "Allen Browne"
<Al*********@Se eSig.Invalid> wrote:
It's a little hard to guess the reason when we have no idea what is in
qryOwnrsDueITS wMissingAddr, whether parameters function calls, or de-duping
could cause different results every time it is run.

You are absolutely right about that. Here's the SQL:

SELECT tblOwners.Owner FName, tblOwners.Owner LName,
tblOwners.Owner Addr, tblOwners.Owner City, tblOwners.Owner State,
tblOwners.Owner Zip, tblOwners.Corpo ration,
MakeITS([OwnerFName],[OwnerLName],[OwnerAddr],[OwnerCity],[OwnerState],[OwnerZip],[Corporation],[tblVehicleJobs].[VehicleJobID])
AS BodyText, tblVehicleJobs. VehicleJobID
FROM (tblOwners RIGHT JOIN tblVehicleJobs ON tblOwners.Owner ID =
tblVehicleJobs. OwnerID) INNER JOIN tblCorresponden ce ON
tblVehicleJobs. VehicleJobID = tblCorresponden ce.VehicleJobID
WHERE (((tblOwners.Ow nerAddr) Is Null) AND
((tblCorrespond ence.OutDate) Is Null) AND
((tblCorrespond ence.OutType)=" 17")) OR (((tblOwners.Ow nerCity) Is
Null) AND ((tblCorrespond ence.OutDate) Is Null) AND
((tblCorrespond ence.OutType)=" 17")) OR (((tblOwners.Ow nerState) Is
Null) AND ((tblCorrespond ence.OutDate) Is Null) AND
((tblCorrespond ence.OutType)=" 17")) OR (((tblOwners.Ow nerZip) Is Null)
AND ((tblCorrespond ence.OutDate) Is Null) AND
((tblCorrespond ence.OutType)=" 17"));

Jan 12 '06 #3
Well, I cannot see any valid reason for DCount() getting that wrong.

The query is relatively simple. You could try dropping the function call to
MakeITS() and see if that makes any difference. (It will certainly affect
the performance of the query, but should not affect the record count.)

The WHERE clause is equivalent to:
WHERE (tblCorresponde nce.OutDate Is Null)
AND (tblCorresponde nce.OutType = "17")
AND ((tblOwners.Own erAddr Is Null)
OR (tblOwners.Owne rCity Is Null)
OR (tblOwners.Owne rState Is Null)
OR (tblOwners.Owne rZip Is Null))

Presumably OutType is a Text type field (not a Number type field.)

There's an outer join, but that should be fine. There are no calcualted
fields in the WHERE clause, no de-dupe. Hard to see how to could get it
wrong.

You did try the compact/repair?

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"MLH" <CR**@NorthStat e.net> wrote in message
news:sp******** *************** *********@4ax.c om...
On Thu, 12 Jan 2006 22:38:16 +0800, "Allen Browne"
<Al*********@Se eSig.Invalid> wrote:
It's a little hard to guess the reason when we have no idea what is in
qryOwnrsDueIT SwMissingAddr, whether parameters function calls, or
de-duping
could cause different results every time it is run.

You are absolutely right about that. Here's the SQL:

SELECT tblOwners.Owner FName,
tblOwners.Owner LName,
tblOwners.Owner Addr,
tblOwners.Owner City,
tblOwners.Owner State,
tblOwners.Owner Zip, tblOwners.Corpo ration,
MakeITS([OwnerFName],[OwnerLName],[OwnerAddr],
[OwnerCity],[OwnerState],[OwnerZip],[Corporation],
[tblVehicleJobs].[VehicleJobID]) AS BodyText,
tblVehicleJobs. VehicleJobID
FROM (tblOwners RIGHT JOIN tblVehicleJobs
ON tblOwners.Owner ID = tblVehicleJobs. OwnerID)
INNER JOIN tblCorresponden ce
ON tblVehicleJobs. VehicleJobID = tblCorresponden ce.VehicleJobID
WHERE ((tblOwners.Own erAddr Is Null)
AND (tblCorresponde nce.OutDate Is Null)
AND (tblCorresponde nce.OutType ="17"))
OR ((tblOwners.Own erCity Is Null)
AND (tblCorresponde nce.OutDate Is Null)
AND (tblCorresponde nce.OutType ="17"))
OR ((tblOwners.Own erState Is Null)
AND (tblCorresponde nce.OutDate Is Null)
AND (tblCorresponde nce.OutType = "17"))
OR ((tblOwners.Own erZip Is Null)
AND (tblCorresponde nce.OutDate Is Null)
AND (tblCorresponde nce.OutType = "17"));
Jan 12 '06 #4
What is the code for MakeITS?

Jan 12 '06 #5
MLH
On 12 Jan 2006 09:33:05 -0800, "Lyle Fairfield"
<ly***********@ aim.com> wrote:
What is the code for MakeITS?

Function MakeITS(OwnerFN ame As Variant, OwnerLName As Variant,
RecipAddr As Variant, OwnerCity As Variant, _
OwnerState As Variant, OwnerZip As Variant, Corporation As Variant,
VehicleJobID As Variant) As String
'************** *************** *************** *************** ***********
' This function is called by qryITSLetterLis t, which furnishes all the
' arguments to this function.
'************** *************** *************** *************** ***********
100 On Error GoTo MakeITS_Err

110 Dim TheOwner As String, TheName As String, TheAddr As String,
TheCSZ As String, ThePhone As String
120 Dim TheCity As String, TheState As String, TheZip As String,
RecipName As String, RecipCSZ As String
130 TheOwner = DLookup("[TheOwnerFName]", "tblAdmin") & " " &
DLookup("[TheOwnerLName]", "tblAdmin")
140 TheName = DLookup("[Thempany]", "tblAdmin")
150 TheAddr = DLookup("[TheAddr]", "tblAdmin")
160 TheCity = DLookup("[TheCity]", "tblAdmin")
170 TheState = DLookup("[TheState]", "tblAdmin")
180 TheZip = DLookup("[TheZip]", "tblAdmin")
190 ThePhone = Format$(DLookup ("[ThePhn]", "tblAdmin") , "(@@@)
@@@-@@@@")
200 TheCSZ = TheCity & ", " & TheState & " " & TheZip
210 If Corporation = False Then RecipName = Nz(OwnerFName) & " " &
Nz(OwnerLName) Else RecipName = Nz(OwnerFName)
220 If RecipName = "" Or RecipName = " " Or IsNull(RecipNam e) Then
RecipName = "Owner Name Unknown"
230 RecipCSZ = Nz(OwnerCity) & ", " & Nz(OwnerState) & " " &
Nz(OwnerZip)
240 If RecipCSZ = ", " Then RecipCSZ = "Owner City/State/Zip
Unknown"

' NOTICE OF INTENT TO SELL A VEHICLE TO SATISFY
STORAGE AND/OR MECHANIC’S LIEN FORM LETTER

250 MyString = "Date: " & Format$(Now, "Long Date") & CRLF & CRLF

260 MyString = MyString & "To:" & CRLF & RecipName & CRLF &
Nz(RecipAddr, "Owner Address Unknown") & CRLF & Nz(RecipCSZ) & CRLF &
CRLF

270 MyString = MyString & "From:" & CRLF & TheOwner & CRLF & TheName &
CRLF & TheAddr & CRLF & TheCSZ & CRLF & ThePhone & CRLF & CRLF

280 MyString = MyString & "The person or firm shown in Section F of
the enclosed NOTICE OF INTENT TO SELL A VEHICLE TO SATISFY STORAGE
AND/"
290 MyString = MyString & "OR MECHANICS LIEN form intends to sell the
vehicle described on the form to satisfy a mechanic’s and/"
300 MyString = MyString & "or storage lien. The amount of the lien,
the services for which the lien is claimed, and the date the lien
became "
310 MyString = MyString & "due are indicated in Section C and D of the
form." & CRLF & CRLF

320 MyString = MyString & "If you feel the lien described in Section C
of the enclosed form is invalid, or you wish to question the validity
"
330 MyString = MyString & "of the lien, you have the right to a
judicial hearing to determine the validity of the lien. To question
the valid"
340 MyString = MyString & "ity of the lien, you must notify the lienor
by completing the request for judicial hearing that appears at the
bottom "
350 MyString = MyString & "of this page and you must return this
letter to the lienor at the address indicated in Section F of the
enclosed NOTICE "
360 MyString = MyString & "OF INTENT TO SELL A VEHICLE TO SATISFY
STORAGE AND/OR MECHANIC’ LIEN form by registered mail or certified "
370 MyString = MyString & "mail, return receipt requested, within ten
(10) days." & CRLF & CRLF

380 MyString = MyString & "Your Failure to return this letter with the
Request For A Judicial Hearing properly completed to the lienor within
"
390 MyString = MyString & "ten (10) days from the date you received
this letter will be considered a waiver of your rights to a hearing
prior "
400 MyString = MyString & "to the sale of this vehicle and the lienor
may enforce the lien by selling the vehicle. If you send the Request
for "
410 MyString = MyString & "a Judicial Hearing to the lienor within the
10 day time period, it will be the responsibility of the lienor to
initiate "
420 MyString = MyString & "the proper action in a court of competent
jurisdiction." & CRLF & CRLF

430 MyString = MyString & "Thank you for your prompt attention to this
matter." & CRLF & CRLF & CRLF
440 CurrentVehicleJ obID = VehicleJobID
450 Dim ccParties As String, MyDB As Database, MyQdef As QueryDef,
MyRecSet As Recordset
452 ccParties = "cc:" & CRLF
460 Set MyDB = CurrentDb()
470 Set MyQdef = MyDB.CreateQuer yDef("", "Select * FROM
qryAuthsOwnersA ddnlOwnersLienh olders4OneCar")
480 With MyQdef
490 Set MyRecSet = .OpenRecordset( dbOpenSnapshot)
500 MyRecSet.MoveFi rst
510 With MyRecSet
520 Do Until MyRecSet.EOF
522 If !OLAX <> "O" Then
530 ccParties = ccParties & !Item
532 End If
540 .MoveNext
550 ccParties = ccParties & CRLF
560 Loop
570 End With
580 End With
590 MyString = MyString & ccParties
600 MakeITS = MyString

MakeITS_Exit:
Exit Function

MakeITS_Err:
Dim r As String, z As String, Message3 As String
r = "The following unexpected error occurred in Function
MakeITS(), line #" & CStr(Erl) & " when called from qryITSLetterLis t:"
z = CRLF & CRLF & str$(Err) & ": " & Quote & Error$ & Quote
Message3 = r & z
MsgBox Message3, 48, "Unexpected Error - " & MyApp$ & ", rev. " &
MY_VERSION$
Resume MakeITS_Exit

End Function
Jan 12 '06 #6
So what are we left with?

470 Set MyQdef = MyDB.CreateQuer yDef("", "Select * FROM
qryAuthsOwnersA ddnlOwnersLienh olders4OneCar")
One wonders why a redundant temporary querydef is created? And, does,
perhaps, qryAuthsOwnersA ddnlOwnersLienh olders4OneCar call a UDF that
creates new records?

What else?
Access/Jet is in error? Over 7 years posting and reading here I have
seen this, what, once for sure, perhaps another time or two, but these
latter have not been so serious. (The documentation is in error
frequently but that's another issue.)

Perhaps, there is something that you have not considered to be
important enough to tell us.

And perhaps you are in error when you report the varying results. From
far afield it is difficult to tell. When I come upon a situation like
this I say a few prayer-like words and rewrite the whole procedure from
scratch.

Jan 12 '06 #7
MLH
On 12 Jan 2006 13:39:40 -0800, "Lyle Fairfield"
<ly***********@ aim.com> wrote:
So what are we left with?

470 Set MyQdef = MyDB.CreateQuer yDef("", "Select * FROM
qryAuthsOwners AddnlOwnersLien holders4OneCar" )
One wonders why a redundant temporary querydef is created? And, does,
perhaps, qryAuthsOwnersA ddnlOwnersLienh olders4OneCar call a UDF that
creates new records?

What else?
Access/Jet is in error? Over 7 years posting and reading here I have
seen this, what, once for sure, perhaps another time or two, but these
latter have not been so serious. (The documentation is in error
frequently but that's another issue.)

Perhaps, there is something that you have not considered to be
important enough to tell us.

And perhaps you are in error when you report the varying results. From
far afield it is difficult to tell. When I come upon a situation like
this I say a few prayer-like words and rewrite the whole procedure from
scratch.


I'll dig some more, to see what surfaces. Maybe I can strip out all
superflous material and post a bare bones illustration of the prob.
Hopefully, it'll resolve before then.
Jan 13 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2048
by: brendan_gallagher_2001 | last post by:
Hi, I have a view(A) and I am trying to do a join on another table (B) to include only rows where date values in view A is greater than in table B. I also want the view to pick up rows in viewA based on date values. Here is what I have so far: SELECT * FROM viewA vw left JOIN tableB tb ON
6
3314
by: Mike Conklin | last post by:
This one really has me going. Probably something silly. I'm using dcount for a report to determine the number of different types of tests proctored in a semester. My report is based on a parameter query which is the recordsource for the report. The parameter is <=. The query returns the correct amounts upto the date entered (no need for "between" dates here). There are 8 textboxes with dcounts; 2 other boxes Sum some of these
15
2958
by: sara | last post by:
Hi I'm pretty new to Access here (using Access 2000), and appreciate the help and instruction. I gave myself 2.5 hours to research online and help and try to get this one, and I am not getting it. Simple database: I want to have a user enter Supply Orders (just for tracking purposes) by Item. The user may also enter a new item - "new" is a combination of Item, PartNumber and Vendor - they could have the
3
2742
by: Zlatko Matiæ | last post by:
Hello. I'm wondernig what is happennig whith saved pass-through queries nested in regular JET query if regular JET query just filtrates result by start/end date...Does pass-through query first returns all rows from server and then JET filtrates result by start/end date, or JET first communicates with server so that server returns only those rows that JET query would return after filtering by start/end date criteria ? For example, let's...
3
3325
by: BerkshireGuy | last post by:
I am having difficulty with using the Dcount function. I am trying to return the number of records from qryIndividualFeedbackDetail where the TimelyManner field is set to 4. So, in the new query I am trying the following: NumOfYes: Dcount(,"qryIndividualFeedbackDetail",=4) The query is counting ALL of the timely manners and is ignoreing my
13
6581
by: MLH | last post by:
Suppose I have this simple SQL string... SELECT tblDrivers.DriverID, tblDrivers.DName FROM tblDrivers WHERE (((tblDrivers.DName) Like "N*")) ORDER BY tblDrivers.DriverID; And suppose that its not a saved querydef - just an SQL string that I cooked up in code and assigned to a global var strMySQL.
1
2153
by: Blue Lagoon Products - Customer Services | last post by:
Hi, Here is my expression =DCount("","tblDownload")>2 I would like to know how many records (including this one?) contain the same 'Buyer ID' as that in txtBuyerID on my report, is this correct ? --
7
32017
by: Michael R | last post by:
Good afternoon. I'm stucked in composing the syntax for DCount expression in a select query. The query qryCustomers has CustomerID field, the DCount function uses tblLoans with LoanDate and Id fields and the expression field should be: DCount("LoanDate","tblLoans","Id=CustomerID"), but the query says it can't find the expression parameter. note: the query does work if the experssion uses an ID number for the criteria, for example:...
2
17648
by: =?Utf-8?B?Q2hyaXM=?= | last post by:
How can I run this query against a table in my Access database? I don't know hwo to use it in C#. In VB I would use .Recordset = "some sql statement". How do I do this in C#? //I get a vlaue form a cell and apply it to the SQL statement commandCol = scriptDataGridView.FormattedValue.ToString(); string sCommand = "SELECT CommandString FROM Commands WHERE CommandName = " + commandCol; //This reutne a valie SQL statement which will return...
0
8471
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8817
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8593
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7423
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6218
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4396
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2804
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2046
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1799
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.