type 13 mismatch error 
Author Message
 type 13 mismatch error

Hi all. I have a bit of code that I want to run when a Database starts up.
It has to run a query, then send an email if the query shows up a particular
result.

However, I am getting an error as soon as the database opens. It is a Run
Time Error 13, type mismatch and it seems to be having a problem with this
line of code:

Set recOverBudget = db.OpenRecordset("qryGetoverbudget")

The query name is spelt correctly, and definetly returns results.

Any Idea what is going on?

Here is all the code:

Public Sub checkit()

' Start up code run when database is started. It will send an email to
notify the admin of which clients are over budget
' Define some variables first

    Dim db              As Database                 ' current database
    Dim recOverBudget   As Recordset                ' recordset of those
client over budget
    Dim objOutlook      As New Outlook.Application  ' outlook object
    Dim objMessage      As MailItem                 ' outlook mail message
    Dim strMessageBody  As String                   ' body of email message

' open the database and recordset of clients over budget

    Set db = CurrentDb()
    Set recOverBudget = db.OpenRecordset("qryGetoverbudget")

    ' now create a list of clients to add to the body of the email

    While Not recOverBudget.EOF

     ' create a string containing the order details

        strMessageBody = strMessageBody & "," & recOverBudget("Client")

    recOverBudget.MoveNext

    Wend

    ' Now send the email to the administrator, informing them which clients
are over budget this month

        Set objMessage = objOutlook.CreateItem(olMailItem)
            With objMessage

                .Subject = "New Order"
                .Body = "The following clients are over budget this month" &
vbCrLf & vbCrLf & strMessageBody
                .Send
            End With

End Sub

Regards

Will



Sun, 28 Sep 2003 19:14:06 GMT  
 type 13 mismatch error
Will:

The problem is likely with your query.  If you have any type of expression
in the query such as CCur() or any thing else that expects a non-null value
and you return a null to the field, you will encounter a type mis-match.

HTH
--
Steve Arbaugh
ATTAC Consulting Group
http://ourworld.compuserve.com/homepages/attac-cg


Quote:
> Hi all. I have a bit of code that I want to run when a Database starts up.
> It has to run a query, then send an email if the query shows up a
particular
> result.

> However, I am getting an error as soon as the database opens. It is a Run
> Time Error 13, type mismatch and it seems to be having a problem with this
> line of code:

> Set recOverBudget = db.OpenRecordset("qryGetoverbudget")

> The query name is spelt correctly, and definetly returns results.

> Any Idea what is going on?

> Here is all the code:

> Public Sub checkit()

> ' Start up code run when database is started. It will send an email to
> notify the admin of which clients are over budget
> ' Define some variables first

>     Dim db              As Database                 ' current database
>     Dim recOverBudget   As Recordset                ' recordset of those
> client over budget
>     Dim objOutlook      As New Outlook.Application  ' outlook object
>     Dim objMessage      As MailItem                 ' outlook mail message
>     Dim strMessageBody  As String                   ' body of email
message

> ' open the database and recordset of clients over budget

>     Set db = CurrentDb()
>     Set recOverBudget = db.OpenRecordset("qryGetoverbudget")

>     ' now create a list of clients to add to the body of the email

>     While Not recOverBudget.EOF

>      ' create a string containing the order details

>         strMessageBody = strMessageBody & "," & recOverBudget("Client")

>     recOverBudget.MoveNext

>     Wend

>     ' Now send the email to the administrator, informing them which
clients
> are over budget this month

>         Set objMessage = objOutlook.CreateItem(olMailItem)
>             With objMessage

>                 .Subject = "New Order"
>                 .Body = "The following clients are over budget this month"
&
> vbCrLf & vbCrLf & strMessageBody
>                 .Send
>             End With

> End Sub

> Regards

> Will



Sun, 28 Sep 2003 19:32:28 GMT  
 type 13 mismatch error
Actually, that would cause Invalid Use of Null.

Probably Access 2000 and you have an ADO reference before your DAO one? So
that the "Recordset" variable is an ADO recordset?

Trying to assign a DAO recordset to it causes a type mismatch.

--
MichKa

the only book on internationalization in VB at
http://www.i18nWithVB.com/


Quote:
> Will:

> The problem is likely with your query.  If you have any type of expression
> in the query such as CCur() or any thing else that expects a non-null
value
> and you return a null to the field, you will encounter a type mis-match.

> HTH
> --
> Steve Arbaugh
> ATTAC Consulting Group
> http://ourworld.compuserve.com/homepages/attac-cg



> > Hi all. I have a bit of code that I want to run when a Database starts
up.
> > It has to run a query, then send an email if the query shows up a
> particular
> > result.

> > However, I am getting an error as soon as the database opens. It is a
Run
> > Time Error 13, type mismatch and it seems to be having a problem with
this
> > line of code:

> > Set recOverBudget = db.OpenRecordset("qryGetoverbudget")

> > The query name is spelt correctly, and definetly returns results.

> > Any Idea what is going on?

> > Here is all the code:

> > Public Sub checkit()

> > ' Start up code run when database is started. It will send an email to
> > notify the admin of which clients are over budget
> > ' Define some variables first

> >     Dim db              As Database                 ' current database
> >     Dim recOverBudget   As Recordset                ' recordset of those
> > client over budget
> >     Dim objOutlook      As New Outlook.Application  ' outlook object
> >     Dim objMessage      As MailItem                 ' outlook mail
message
> >     Dim strMessageBody  As String                   ' body of email
> message

> > ' open the database and recordset of clients over budget

> >     Set db = CurrentDb()
> >     Set recOverBudget = db.OpenRecordset("qryGetoverbudget")

> >     ' now create a list of clients to add to the body of the email

> >     While Not recOverBudget.EOF

> >      ' create a string containing the order details

> >         strMessageBody = strMessageBody & "," & recOverBudget("Client")

> >     recOverBudget.MoveNext

> >     Wend

> >     ' Now send the email to the administrator, informing them which
> clients
> > are over budget this month

> >         Set objMessage = objOutlook.CreateItem(olMailItem)
> >             With objMessage

> >                 .Subject = "New Order"
> >                 .Body = "The following clients are over budget this
month"
> &
> > vbCrLf & vbCrLf & strMessageBody
> >                 .Send
> >             End With

> > End Sub

> > Regards

> > Will



Sun, 28 Sep 2003 21:25:38 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Worked fine yesterday, today I get Error 13 Type Mismatch errors

2. Error 13: Type Mismatch error

3. Type Mismatch Run-Time error 13

4. Type Mismatch Error 13

5. type mismatch error '13'????

6. Using CurrentDB() receives Type Mismatch Error 13

7. Type mismatch, run-time error #13

8. ACC2000:Run Time Error '13': Type Mismatch

9. Invalid Reference (Error 13 - Type Mismatch)

10. Run -time error '13' Type Mismatch

11. Run-time error '13': Type mismatch

 

 
Powered by phpBB® Forum Software