Select particular records in a query

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm running a query on a table containing around 4000 names. How can I
select, retrieve and show the data for 2-12 names only. And also to show
their last 6 entries only as I don't want to show all their entries.
Thanks
 
I'm running a query on a table containing around 4000 names. How can I
select, retrieve and show the data for 2-12 names only. And also to show
their last 6 entries only as I don't want to show all their entries.
Thanks

Could you explain what "2-12" names means? Do you want to see two
names, six names, twelve names?

An Access Table has no order. It's a "bucket" of data. So there is no
way to identify "the last 6 entries" unless you have something in the
table itself which orders the entries, such as a datestamp or
sequential number.

Take a look at the Top Values property of a query - it might be
helpful with what you're trying to do. But I'd REALLY suggest creating
a Form to display your data - you can control the size of a continuous
form to show any desired number of records, sort them however you
like, etc.

John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
 
I'm running the query as a form but I need to show a selection. I want to
select several names varying from 2 to 12 and show them on the report. How
can I write the criteria in the query to select the names I want?? I'm
trying [name?] Or [name?] on the criteria field but its not working like
this. Excuse my ignorance.

Sph1197
 
I'm running the query as a form but I need to show a selection. I want to
select several names varying from 2 to 12 and show them on the report. How
can I write the criteria in the query to select the names I want?? I'm
trying [name?] Or [name?] on the criteria field but its not working like
this. Excuse my ignorance.

So you want the user to be able to type several names, and have it
search for the entered names using OR logic? This should be easier
than it is, unfortunately!

One suggestion would be to have twelve unbound textboxes, Name1 to
Name12 say, on a Form; and use a criterion of

IN ([Forms]![YourForm]![Name1], [Forms]![YourForm]![Name2],
[Forms]![YourForm]![Name3], <etc>)

in your query. The other suggestion would be to write VBA code to poll
through the form and build up a SQL string in code, and then set that
string as the report's Recordsource.

John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
 
Back
Top