473,398 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Why does a query count (with GROUP BY) indicate more records than there are??

Hallo,

Indeed, a count of a query with a group by function gives more records than
there are and so for-next structures don't function.
How is this to be mended.
Anyone? Everyone in fact.
Answers are greatly appreciated.
--

mvg Hyphessobrycon
Nov 21 '05 #1
3 1645
Hi,

Post some code.

Ken
-----------
"Hyphessobricon" <sy*********@telenet.be> wrote in message
news:lW*******************@phobos.telenet-ops.be...
Hallo,

Indeed, a count of a query with a group by function gives more records than
there are and so for-next structures don't function.
How is this to be mended.
Anyone? Everyone in fact.
Answers are greatly appreciated.
--

mvg Hyphessobrycon

Nov 21 '05 #2

"Ken Tucker [MVP]" <vb***@bellsouth.net> schreef in bericht
news:eO**************@TK2MSFTNGP15.phx.gbl...
Hi,

Post some code.

Ken
-----------
"Hyphessobricon" <sy*********@telenet.be> wrote in message
news:lW*******************@phobos.telenet-ops.be...
Hallo,

Indeed, a count of a query with a group by function gives more records
than
there are and so for-next structures don't function.
How is this to be mended.
Anyone? Everyone in fact.
Answers are greatly appreciated.
--

mvg Hyphessobrycon


So, in my Module1
the count says : 5 rows in table
and th'n an error no row at 2
in the query there are indeed only 2 rows, an din the table there are 5, but
I work with the query.

Private Sub brandstof1() 'huisbrandolie

i = dtqBs1.Rows.Count '=dtBS1 is for the tbl, dtqBs1 is the query,
everything containing q is for the query

MsgBox("brandstofrijen " & i) '= here I get the 5 rows

Dim dattum As Date

For i = 0 To i - 1

'query gebruikt om de laatst ingevoerde te tonen

If dsqBrandstof1.Tables(0).Rows(i).Item("Brandstofjaa r") = CInt(Year(Now()))
Then '= the query dataset

frmVariabele.lblStookVJ.Text = Format(dsqBrandstof1.Tables(0).Rows(i -
1).Item("SomvanBrandstof"), "0.00")

frmVariabele.txtGasT.Text =
Format(dsqBrandstof1.Tables(0).Rows(i).Item("Somva nBrandstof"), "0.00")

frmVariabele.lblVersStook.Text = Format(Val(frmVariabele.lblStookVJ.Text) -
Val(frmVariabele.txtGasT.Text), "0.00")

End If

Next i

i = dsBrandstof1.Tables(0).Rows.Count =that is the regular table dataset

For i = 0 To i - 1

If dsBrandstof1.Tables(0).Rows(i).Item("Brandstofdatu m") > dattum Then

dattum = dsBrandstof1.Tables(0).Rows(i).Item("Brandstofdatu m")

End If

Next i

For i = 0 To i - 1

If dsBrandstof1.Tables(0).Rows(i).Item("Brandstofdatu m") = dattum Then

frmVariabele.txtGas.Text =
Format(dsBrandstof1.Tables(0).Rows(i).Item("Brands tof"), "0.00")

frmVariabele.txtGasDat.Text =
dsBrandstof1.Tables(0).Rows(i).Item("Brandstofinfo ")

frmVariabele.txtGadat.Text =
dsBrandstof1.Tables(0).Rows(i).Item("Brandstofdatu m")

End If

Next

End Sub
Nov 21 '05 #3
Hi,

Think the problem is with your for loop. for i=0 to i-1. try this
instead

dim intRows as integer = dtqBs1.Rows.Count

For i = 0 To intRows - 1
Ken
------------------------

"Hyphessobricon" <sy*********@telenet.be> wrote in message
news:E2*******************@phobos.telenet-ops.be...

"Ken Tucker [MVP]" <vb***@bellsouth.net> schreef in bericht
news:eO**************@TK2MSFTNGP15.phx.gbl...
Hi,

Post some code.

Ken
-----------
"Hyphessobricon" <sy*********@telenet.be> wrote in message
news:lW*******************@phobos.telenet-ops.be...
Hallo,

Indeed, a count of a query with a group by function gives more records
than
there are and so for-next structures don't function.
How is this to be mended.
Anyone? Everyone in fact.
Answers are greatly appreciated.
--

mvg Hyphessobrycon


So, in my Module1
the count says : 5 rows in table
and th'n an error no row at 2
in the query there are indeed only 2 rows, an din the table there are 5, but
I work with the query.

Private Sub brandstof1() 'huisbrandolie

i = dtqBs1.Rows.Count '=dtBS1 is for the tbl, dtqBs1 is the query,
everything containing q is for the query

MsgBox("brandstofrijen " & i) '= here I get the 5 rows

Dim dattum As Date

For i = 0 To i - 1

'query gebruikt om de laatst ingevoerde te tonen

If dsqBrandstof1.Tables(0).Rows(i).Item("Brandstofjaa r") = CInt(Year(Now()))
Then '= the query dataset

frmVariabele.lblStookVJ.Text = Format(dsqBrandstof1.Tables(0).Rows(i -
1).Item("SomvanBrandstof"), "0.00")

frmVariabele.txtGasT.Text =
Format(dsqBrandstof1.Tables(0).Rows(i).Item("Somva nBrandstof"), "0.00")

frmVariabele.lblVersStook.Text = Format(Val(frmVariabele.lblStookVJ.Text) -
Val(frmVariabele.txtGasT.Text), "0.00")

End If

Next i

i = dsBrandstof1.Tables(0).Rows.Count =that is the regular table dataset

For i = 0 To i - 1

If dsBrandstof1.Tables(0).Rows(i).Item("Brandstofdatu m") > dattum Then

dattum = dsBrandstof1.Tables(0).Rows(i).Item("Brandstofdatu m")

End If

Next i

For i = 0 To i - 1

If dsBrandstof1.Tables(0).Rows(i).Item("Brandstofdatu m") = dattum Then

frmVariabele.txtGas.Text =
Format(dsBrandstof1.Tables(0).Rows(i).Item("Brands tof"), "0.00")

frmVariabele.txtGasDat.Text =
dsBrandstof1.Tables(0).Rows(i).Item("Brandstofinfo ")

frmVariabele.txtGadat.Text =
dsBrandstof1.Tables(0).Rows(i).Item("Brandstofdatu m")

End If

Next

End Sub

Nov 21 '05 #4

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

Similar topics

20
by: | last post by:
If I need to check if a certain value does exist in a field, and return either "yes" or "not" which query would be the most effestive?
3
by: Glenn Carr | last post by:
I'm trying to count the number of records in 'game_dates' where the columns home_team_id or away_team_id have the same value. E.g., i want to know the number of records for each team_id where...
6
by: Ljoha | last post by:
I need to create report where will be shown total quantity of all rows for every hour in some data range. I have a table where I have column in DATETIME format. I have problem to create sql...
10
by: Thomas R. Hummel | last post by:
I have a stored procedure that suddenly started performing horribly. The query plan didn't look right to me, so I copy/pasted the code and ran it (it's a single SELECT statement). That ran pretty...
5
by: Alicia | last post by:
Yes, but will that skip a week and group by the date for me? I basically wanted something that would do a count of the dates, then group them by their week name.. BEFORE: Resource Date ...
4
by: Tom | last post by:
An order may be rescheduled to ship multiple times. The tables look like: TblOrder OrderID <order fields> TblOrderShip OrderShipID OrderID ShipDate ReasonNotShipped
4
by: frizzle | last post by:
Hi there, Still building my forum. I have a certain mysql-query i just can't figure out. These are my tables (simplified): categories -> id, description forums -> id, cat_id,...
1
by: NewUser | last post by:
I try this: A first "group" query (sorry if this isn't the right name) count the records from a table with a criteria (field1="A") and return counter1=10 records. A second "group" query count the...
12
by: petter | last post by:
Hi! I have two questions: one question that regards the COUNT-function, and one about how to display a month even if I don’t have any data for that month. I have an Access database where I want...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...
0
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,...
0
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...

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.