Type Mismatch using recordset on external DB

G

Guest

Dim DB As Database
Dim rs As Recordset
Dim Qry1 as string

Qry1 = "SELECT * FROM Employer"

Set DB = DBEngine.Workspaces(0).OpenDatabase("D:/Mydb.mdb")
Set rs = DB.OpenRecordset(Qry1, dbOpenSnapshot)

why does set rs give me a type mismatch error? I have a reference to DAO set.
(e-mail address removed)
 
G

Guest

Actually I'm pulling it from a combobox, so the address doesn't matter.
(e-mail address removed)
 
G

Guest

I think I got it. Since I have references to ADO and DAO it seemed to help to
use
dim rs as DAO.recordset

Still having a problem with null though.
Don't know how to get around it. If I need a value but its null, I have to
avoid an error or resume next.
(e-mail address removed)
 
A

Allen Browne

If you are attempting to assign the value of a field to a variable in VBA,
you need to be aware that the Variant is the only data type than can have
the value Null. Declare a variant, or use Nz() to specify a value to use in
place of null.

More info in article:
Common errors with Null
at:
http://allenbrowne.com/casu-12.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top