As Zmbd says, please try to include the basics of the question so we have something to work with. I get so frustrated by questions claiming something doesn't work without indicating what was expected (and why) and what was actually perceived when it was run.
It's clear you have tried to include helpful information so I can see this is simple inexperience, but do make a note for future requests.
Avoid relying on information (such as the contents of strSQL) that isn't shared in the question. Always include relevant error messages. Numbers are fine too, but always as well as & never instead of. When using code only EVER use code that has been copied & pasted from your project. I see rs.movenext
on line #11 & immediately recognise this is either not from your actual code or you have created something else, within that project, called movenext
that includes no capitals.
As I say, it's clear you're inexperienced in using forums, so just see this as helpful advice from an old-timer :-)
Otherwise, quite well explained and all we really need now is the stuff I explained above. I have to say, nothing jumps out immediately. If line #7 works, as you say, then it would appear that rs
is set up appropriately. You don't explain what 'works' means in this context, which is important because not crashing and assigning a visible value could both be meant, and they have vastly different implications.
In spite of that, not crashing would imply a recordset were correctly set up - even if it might be an empty one. As such I would certainly expect line #9 to compile and run - unless you interpret the failure to proceed to line #11 as an error of course. Your explanation isn't exactly clear so we will probably have to wait for your full information and hope something shows that may explain your situation.
I can say that, assuming our assumptions of what you mean are accurate, I would not expect to see errors with the code shown.