Thanks for thinking with me but I have it solved!!!
I found the following code and adapted it to my needs.
After defining the querysyntax, I created a temp query (from code) end
using that sql syntax to transferspreadsheet the found data!
SQL = "select mytable.* from mytable where Fieldname in ("
Dim RS As Recordset: Set RS = Forms!Formnae.RecordsetClone
If RS.RecordCount 0 Then RS.MoveFirst
While RS.EOF = False
SQL = SQL & Str$(RS!Fieldname) & ","
RS.MoveNext
Wend
Set RS = Nothing
If Right(SQL, 1) = ")" Then
SQL = SQL & "null)"
Else
Mid(SQL, Len(SQL), 1) = ")"
End If
But now I want to adapt one more thing but that won't work:
I want this part Str$(RS!Fieldname) to be dynamic:
Using something like:
Dim sColumn
Dim Fieldname
sColumn = Fieldname
sFieldname= "Str$(RS!" & sColumn & ")"
This
So if I want to reuse this code with a different field I can simply
change the "sColumn =" ..
But if I do it as shown above gets added to the query as a string :
SQL = SQL & "Str$(RS!Fieldname)" & ","
How do I prevent that sFieldname is considered a string?
Bas Cost Budde schreef:
The latter part, "where the number is one of a set" is best done using
an INNER JOIN between your table and the set of numbers.
What is not clear to me, still, is how you arrive at your set of
numbers. If explaining yourself in Dutch seems a helpful step, be my
guest, do so at bas apestaartje heuveltop punt ennel (now would any
spambot see that as a valid mailadress? :D)
The general idea though in that case is formulated well by Ron2006. Get
a saved query and join to that.
--
Bas Cost Budde
Holland