Access Query

mikeymay

Well-known Member
Joined
Jan 17, 2006
Messages
1,598
Office Version
  1. 365
Platform
  1. Windows
I am wanting to return all records in an Access table that meet a query criteria.

The query I have built via VBA code is -
SELECT ID, Price, QtyOut, ValueOut, InStock, ValueInStock, Allocated FROM GoodsIn WHERE Item = '9oz Squat Plastic Cup' AND DateIn <# 22/08/2019# AND Allocated = False ORDER BY DateIn ASC, QtyIn ASC

There are 2 records in the table that meet the criteria but the query is only returning 1 record.

I am using the following to open and read the recordset
Code:
rsQuery.Open strQuery, cnConnection, adOpenKeyset, adLockOptimistic

I have used this code before to return all matching records so I am at a bit of a loss as to why this is n't working.

Any insights provided would be hugely appreciated.

TIA
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
The query looks okay except I'm not used to seeing boolean False as a value in Access query. Access uses numeric values to store true and false (-1 and 0 respectively). Otherwise, you'd probably have to post your code and some sample data in order to debug and test this.
 
Upvote 0
Can you post the two records you are expecting it to return?
 
Upvote 0
Thanks for the input all. I managed to get this to work without fixing anything so not entirely sure why it didn't work initially.
 
Upvote 0

Forum statistics

Threads
1,213,504
Messages
6,114,020
Members
448,543
Latest member
MartinLarkin

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