Cycling through a recordset (1 Viewer)

harrisw

Registered User.
Local time
Today, 04:31
Joined
Mar 27, 2001
Messages
131
I have the SQL below

SQL = "SELECT TOP 300 FROM [EXPORT]WHERE [DISTRICT]=" & """RSnEW(0) " & " ORDER BY [EMPLOYEE SIZE];"

I want to put it in a loop so that it will cycle through the rsNew recordset running the sql each time.

I get errors on the sql but dont know why

How should the SQL look?
 

harrisw

Registered User.
Local time
Today, 04:31
Joined
Mar 27, 2001
Messages
131
Tried looking for a thread which explains how to do it but cant find anything

The SQL I have put on here just keeps giving an error saying something about a reserved word
 

jgc31

Registered User.
Local time
Today, 04:31
Joined
Dec 4, 2004
Messages
78
Not quite sure what RSnEW(0) is but if it is a string variable of some sort then syntax should be similar to =""" & RSnEW(0) & """" . If it is a recordset then I dont believe that you can include it in the SQL string. DISTRICT has to = a string of somesort which of course could be an individual field in a recordset.
 
M

millerjv

Guest
Reserved words in SQL a real pain

I've been caught by this previously. I think the problem may be the word "EXPORT". Try changing it to something like mEXPORT (and the name of the table too of course or you will get the message "table not found or similar"
Hope this helps. :)
 

Users who are viewing this thread

Top Bottom