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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Prompt for Top Values

Status
Not open for further replies.

2176

MIS
Sep 7, 2002
29
0
0
US
I have a module running that randomly picks x% and displays it in a query. I know that you can manually go in and change the amount in the query properties, but I'm the creator and I know how to do that, but those that are going to be using the database are unfamilar with how that works. So my question is how do I get a prompt to enter a Top Value so that it randomly picks only the amount of records needed.

Toy
 
Toy,

If you're using a module, you can define a variable and use an input box to get a value for that variable. Here's a simple version:

Sub yadda()
Dim varResponse As Variant

varResponse = InputBox("Please enter the % of records " _
& "you would like to view.", "Percent to View")

If Nz(varResponse) = "" Then
'Do nothing.
ElseIf IsNumeric(varResponse) Then
'Run your code here, using varResponse in place of
'the random number you were generating.
Else
Call MsgBox("That's not a number.")
Call yadda
End If
End Sub

Hope this helps.

Jeremy Wallace
AlphaBetCityDataworks.com
 
Actually I have several command buttons with the file numbers so when the button is clicked it runs the module to pick the random number I would like for it to ask how many to pick first and then choose random numbers based on the amount picked. I hope what I wrote is understandable, and all help is appreciated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top