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!

SELECT TOP n, where n is a number recive from a combobox

Status
Not open for further replies.

adita1983

Technical User
Dec 28, 2004
7
0
0
RO
Hi

I want to select first n recordsets from a table in a new table , where n is a variable recived from a combobox in a form.Here is a part of my code :

Private Sub Submit_Click()
Dim strSQL As String
strSQL = "SELECT TOP cint(Me.cmb_Procent) tblTemp.* from tbl into newtable"
DoCmd.RunSQL strSQL

End Sub

I receive the error : The SELECT statement includes a reserve word or an argument name that is misspelled or missing, or the punctuation is incorrect.

Thanks in advance.

Adrian


 
You have inconsistent table names and no Order By clause for your Top N. It needs to look something like this:

strSQL = "SELECT TOP " & cint(Me.cmb_Procent) & " tblTemp.* into newtable from tblTemp Order By somefieldhere desc"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top