Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Flag records in query

Status
Not open for further replies.

RosyGlasses

Programmer
Jan 28, 2013
2
US
Hello, I have a form with two number fields. Sample and Extra.

A query is run against a main table with thousands of rows and returns Sample+Extra records randomly. Ex: If 100 is entered into Sample and 25 in Extra, then 125 records are randomly returned. There is no differentiation in the results between Sample and Extra.

Is there a way to flag the records returned with the first 100 as 'S' and the next 25 as 'E'? It doesn't matter which records get flagged S or E, as long as 100 are S and 25 are E. However, these numbers change depending on what the user enters in the form so any calculation would have to refer to the form fields.

I'm on a convoluted path right now of separate append queries sorted first ascending, then descending, using Top 100/Top 25 variables in strSQL (VBA code) and ending up with a final table. I think I can get it to work but I'm wondering if I'm missing something obvious and cleaner.

Thank you for any insight.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top