"(E-Mail Removed)" <(E-Mail Removed)> wrote in
message news:743701c3e73b$13a4a5b0$(E-Mail Removed)
> I am trying to write my first VBA app to populate a table
> from a subset of another table. However, I keep getting a
> "Run-time error '13': Type Mismatch" on the "Set
> rstWeeks...." line below. (Marked with a "--->")
>
> This is all the code that is written so far. The
> db.openrecordset seems to be working...b/c if I remove the
> "set rstweeks =", code runs fine. From looking at other
> samples...it seems that this is pretty
> straightforward...but am I missing something here? If
> rstWeeks is a recordset and db.openrecordset returns a
> recordset, then what is the problem?
>
> Any help?
>
> Public Sub cmdRunIteration_Click()
>
> Dim db As Database
> Set db = CurrentDb
>
> Dim rstWeeks As Recordset
> --->Set rstWeeks = db.OpenRecordset("Select Ending, SP,
> YieldSP, Yield3mo, Yield10yr FROM Weeks WHERE Ending >
> 1/1/2003")
>
> End Sub
Access 2000 or later, right? You are probably missing the required
reference to the Microsoft DAO 3.6 Object Library, and if you have that
reference and at the same time have a reference to the ActiveX Data
Objects 2.x Library you still need to disambiguate your declaration of
the rstWeeks (because the Recordset object is defined in both
libraries).
First, with any code module open, click Tools -> References..., locate
"Microsoft DAO 3.6 Object Library" in the list and put a check mark next
to it if there isn't one already. Then close the dialog.
Second, change this:
> Dim rstWeeks As Recordset
to this:
Dim rstWeeks As DAO.Recordset
Third, though this isn't the source of the current problem, change this:
> ... WHERE Ending > 1/1/2003")
to this:
... WHERE Ending > #1/1/2003#")
That should do it.
--
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)