When ADODB.Recordset variable not defined isn’t due to a missing reference.

Had a really obscure issue this morning that will probably never happen to anyone else but if it does here you go….

I was trying to compile an older access 2003 ADP that we hadn’t compiled for quite a while and it was failing. I opened up the code editor and ran Debug > Compile.

which resulted in Compile Error: Variable Not Defined on the following line



Now normally this is a result of a missing reference. Code Editor > Tools > References

The missing reference for an error on ADODB would be Microsoft ActiveX Data Objects 2.x Library but my application has that reference. Hmmm.

I spent some time adding & removing and changing versions and still nothing. I’m sitting staring at the screen, coffee in hand, when I noticed something.

Can you see it?






Those quotes are wrong. The VBA code editor is plain text. The quotes in the SET statement are extended character quotes. Not sure how they got there. My guess is that when we had to switch CreateObject due to Windows 7 SP1 , the code was emailed in Outlook, copied from a wordpress blog (which likes these types of quotes) or passed around the office in a Word document.

A simple search & replace of the offending quotes with standard quotes resolved the issue.






Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: