display 3 records out of 5 returned from a query

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

Guest

I have a query that returns several records. Out of the query, I want to
display a user defined amount of those records on a report. I am assuming
that I need an unbound box on my main form to have the user select the amount
of records that they want to see. My question is what my coding is behind
the scenes to display what they ask for.

Thanks!
 
Here's an example using the Categories table from the Northwind sample
database. In this example, 'frmTest' is the form, and 'Text0' is the text
box, where the user enters the number of records to be displayed ...

Private Sub Report_Open(Cancel As Integer)

Dim strSQL As String
Me.RecordSource = "SELECT TOP " & _
Forms!frmTest!Text0 & _
" Categories.* " & _
"FROM Categories ORDER BY " & _
"Categories.CategoryID"

End Sub

Here's a link to the on-line help topic on the TOP predicate ...

http://office.microsoft.com/assistance/hfws.aspx?AssetID=HP010322051033
 
Back
Top