I'm not sure what a TOP clause is. Basically what I'm looking for is something like this:
dim x,y as variant
dim z as interger
z = inputbox("Please enter a number between 1 - 100"
set x = currentdb.createquerydef (""

x.sql = "INSERT INTO TableB SELECT TableA.* FROM TableA"
x.maxrecords = z
x.execute
When I run this it seems to ignore the maxrecords statement and inserts all records. It also doesn't work if I do something like this...
dim x as variant
dim y as string
dim z as interger
z = inputbox("Please enter a number between 1 - 100"

y = inputbox("Enter File name"
set x = currentdb.createquerydef ("temp"

x.sql = "select * from tableA"
x.maxrecords = z
docmd.transfertext actextdelim,,"temp","c:\" & y & ".txt"
This will create the text file but also not be limited to the maxrecords value. I have also tried both ways a hardwired maxrecords value, and have the same results.
The only way have have gotten it to do what I want (sort of) is to do this...
dim w, x as variant
dim y, z as interger
y = InputBox("Number of records?", "Toolbox"
Set x = CurrentDb.CreateQueryDef(""

x.sql = "select * from TableA"
x.returnsrecords = True
z = 0
Set w = x.openrecordset()
Debug.Print "Query Results:"
With w
Do While Not .EOF
z = z + 1
If z < y + 1 Then
Debug.Print , .Fields(0), .Fields(1)
.MoveNext
Else:
GoTo ex_sub
End If
Loop
.Close
End With
This will print the correct number of record in the immediate window, but that isn't exactly useful for me, and in application this process will be handling around 10,000 records. The immediate window seems to only store about 200 lines.
Sorry this is so long but help would be great!
Jay