Setting query TopValue property using VB

  • Thread starter Thread starter Cindy Jones
  • Start date Start date
C

Cindy Jones

Hello there,

Im trying to set the Topvalue query property using VB. Id
like my database users to specify what "topvalue" they'd
like to report on, be it top 5 sales or 50 etc. Can this
be done?

If anybody can help me Id really appreciate it.

Cheers

Cindy Jones
 
Cindy,

You haven't specified how you would feed this to what and
how they would tell you what you want, but you did ask about
doing it in VBA, so here is an example using an InputBox to
get the Top Number into a SQL statement...

Dim strSQL as String
Dim lngAns as String

lngAns = InputBox("How many Top Producers would you like to
see?", "Report Parameters")

strSQL = "SELECT TOP " & lngAns & " FirstName, LastName,
Sales ORDER BY Sales DESC;"


Gary Miller
Sisters, OR
 
Back
Top