I spoke too soon. The problem is that the even though the query becomes a
top X type, the code wipes out the sort ascending in the query whenever I
run it . So, naturally, selecting top values can't work properly.
Debug compile also told me to that I had too many "X as integer" 's,. I
got a msg "Duplicate declaration etc." , so I removed the X etc. on the
second line.
Function FunctionName(X as Integer)
Dim db as DAO.database, myqs as querydef, X as Integer
Set db = CurrentDB
Set myqs = db.QueryDefs("QueryName")
myqs.sql = "SELECT Top " & X & " TableName.* From TableName"
End Function