Rolo
Rolo

Reputation: 97

Inconsistent error when using ADODB in VBA with parameters for RecordSet Open

This line of code:

rs.Open SQLStr, conn, adOpenStatic

is proving somewhat volatile - sometimes it runs with no problem, and sometimes it throws the error:

Variable not defined.

It appears to be the adOpenStatic causing problems. I'm trying to avoid referencing the ADODB library as it would then require all of my users to reference this library. If it didn't work full stop then fine but my frustration stems from the fact that sometimes it works and sometimes it doesn't.

Just wondered if anyone had come across this before and had a solution?

Upvotes: 1

Views: 225

Answers (1)

Kazimierz Jawor
Kazimierz Jawor

Reputation: 19067

When working with external libriary in late-binding mode you can not work with constants like adOpenStatic. Use 3 istead (just three) wich is numeric representation of adOpenStatic.

Other parameters and theirs numeric repesentations you can find here

Upvotes: 1

Related Questions