PC Review


Reply
Thread Tools Rate Thread

Help connecting to a db

 
 
max@maultsby.net
Guest
Posts: n/a
 
      30th Jan 2004
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

 
Reply With Quote
 
 
 
 
Jim Allensworth
Guest
Posts: n/a
 
      30th Jan 2004
On Fri, 30 Jan 2004 06:12:21 -0800, "(E-Mail Removed)"
<(E-Mail Removed)> wrote:

>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
>

You need to enclose date literals with #s

Set rstWeeks = db.OpenRecordset("Select Ending, SP, YieldSP, Yield3mo,
Yield10yr FROM Weeks WHERE Ending >#1/1/2003#")

- Jim
 
Reply With Quote
 
Guest
Posts: n/a
 
      30th Jan 2004
thanks....but I still get the same run-time error.

Any other ideas

>-----Original Message-----
>On Fri, 30 Jan 2004 06:12:21 -0800, "(E-Mail Removed)"
><(E-Mail Removed)> wrote:
>
>>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
>>

>You need to enclose date literals with #s
>
>Set rstWeeks = db.OpenRecordset("Select Ending, SP,

YieldSP, Yield3mo,
>Yield10yr FROM Weeks WHERE Ending >#1/1/2003#")
>
>- Jim
>.
>

 
Reply With Quote
 
Jim Allensworth
Guest
Posts: n/a
 
      30th Jan 2004
What is the Datatype of "Ending"? Is it text?

If it is text (which I would be concerned about) then you need to
enclose the "date" with single quotes.

Yield10yr FROM Weeks WHERE Ending >'#1/1/2003'")


On Fri, 30 Jan 2004 07:52:47 -0800,
<(E-Mail Removed)> wrote:

>thanks....but I still get the same run-time error.
>
>Any other ideas
>
>>-----Original Message-----
>>On Fri, 30 Jan 2004 06:12:21 -0800, "(E-Mail Removed)"
>><(E-Mail Removed)> wrote:
>>
>>>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
>>>

>>You need to enclose date literals with #s
>>
>>Set rstWeeks = db.OpenRecordset("Select Ending, SP,

>YieldSP, Yield3mo,
>>Yield10yr FROM Weeks WHERE Ending >#1/1/2003#")
>>
>>- Jim
>>.
>>


 
Reply With Quote
 
Jim Allensworth
Guest
Posts: n/a
 
      30th Jan 2004
That should be...
Yield10yr FROM Weeks WHERE Ending >'1/1/2003'")

On Fri, 30 Jan 2004 16:14:45 GMT, (E-Mail Removed)
(Jim Allensworth) wrote:

>What is the Datatype of "Ending"? Is it text?
>
>If it is text (which I would be concerned about) then you need to
>enclose the "date" with single quotes.
>
>Yield10yr FROM Weeks WHERE Ending >'#1/1/2003'")
>
>
>On Fri, 30 Jan 2004 07:52:47 -0800,
><(E-Mail Removed)> wrote:
>
>>thanks....but I still get the same run-time error.
>>
>>Any other ideas
>>
>>>-----Original Message-----
>>>On Fri, 30 Jan 2004 06:12:21 -0800, "(E-Mail Removed)"
>>><(E-Mail Removed)> wrote:
>>>
>>>>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
>>>>
>>>You need to enclose date literals with #s
>>>
>>>Set rstWeeks = db.OpenRecordset("Select Ending, SP,

>>YieldSP, Yield3mo,
>>>Yield10yr FROM Weeks WHERE Ending >#1/1/2003#")
>>>
>>>- Jim
>>>.
>>>

>


 
Reply With Quote
 
Dirk Goldgar
Guest
Posts: n/a
 
      30th Jan 2004
"(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)


 
Reply With Quote
 
Guest
Posts: n/a
 
      30th Jan 2004
You're the man! I had the DAO library in....but adding the
"DAO." did the trick.

Thanks!

III
>-----Original Message-----
>"(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)
>
>
>.
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
connecting PCs alice Windows XP Help 4 12th May 2007 06:53 PM
when i am connecting vpn to client my system will not connecting server koteshsvv@gmail.com Microsoft Windows 2000 RAS Routing 1 24th Mar 2007 03:11 PM
Connecting to a Socket on the device when connecting via ActiveSyn =?Utf-8?B?U2ltb24gSGFydA==?= Microsoft Dot NET Compact Framework 5 17th Aug 2006 06:37 PM
Connecting to the IdX =?Utf-8?B?ZG9zaWdlbw==?= Microsoft ADO .NET 0 28th Apr 2005 02:58 PM
Connecting Todd Windows XP General 1 7th Jul 2004 10:24 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:13 PM.