SQL SELECT returns too many rows

dogdays

Active Member
Joined
Apr 28, 2008
Messages
434
Office Version
  1. 2007
Ms Access 2003 win7 32 bit
I have the following SQL statement
Code:
SELECT nIdentity FROM tblPayments WHERE (nHouseholdNumber = 12683 AND nForYear = 2011)

There are eight rows that have household number 12683, only one of the of the eight rows has year 2011. Yet the query returns eight rows.
Advice appreciated.

tia Jack
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
How are you storing the year?

What do the other records have for a value in that field?
 
Upvote 0
nHouseholdNumber is a long integer, nForYear is an integer.
nForYear has the following values:
2005
2006
2007
2008
2009
2009
2010
2011

Jack
 
Upvote 0
Are those eight nForYear values the values you are having returned?

It would seem to suggest that you may have a typo in your statement and maybe mis-typed the field name in your where clause. I would double-check that.
 
Upvote 0
Problem solved. I tested for a record count <> 0, but neglected to movelast movefirst. When I did that the record count dropped to 1.

thanks for the advice
 
Upvote 0
I thought this was a query not a recordset.

Getting a row count for a recordset can sometimes be tricky.
 
Upvote 0
I thought this was a query not a recordset.
Me too!
That is critical information to know, and changes the problem completely.
 
Upvote 0
Norie:
My fault, next time I will be more explicit.

Thanks for the reply Jack
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,286
Members
452,902
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top