Type Mismatch Error 13 
Author Message
 Type Mismatch Error 13

Hi,

I have a problem with a SQL statement. Could anyone give
me any suggestions why the problem occurs?

Problem.
I have a form with 2 unbound fields in it. They are for
Start Date, the other for End Date. They are defaulted to:
Start Date = Today - 30 days, End Date = Today. Simple so
far. I then build the SQL statement to check a date field
is either Greater than Start Date - 1 and Less then End
Date + 1.

        & "WHERE ((Incident.[Date of Incident]) > #" &
([Forms]![Dated Report Selection]![Text1] - 1) & "#" _
        & "And (Incident.[Date of Incident]) < #" &
([Forms]![Dated Report Selection]![Text3] + 1) & "#);"

This all works fine with default dates. I also have no
problem if I change the start date. The SQL is correct and
the resultant table is perfectly correct.

However, if I change the End Date at all, I get an error:

        Description:    Type Mismatch
        Error Code      13

Why can I do an arithmetic function on the Start Date - 1
as well as an arithmetic function on End Date + 1 (when
default) but when I change the date in End Date the
arithmetic function will not work. It appears to be
treating End Date once it has changed as a text string
rather than a date.

Does anyone have any suggestions that could rectify my
problem?

Neil



Tue, 03 May 2005 00:44:19 GMT  
 Type Mismatch Error 13
Not sure why you are having the problem, but you might try using the DateAdd
function to calculate your dates. Or forcing the control's value to be dates by
using CDate around them.  I suspect that Access (VBA) is seeing something like
 12/10/2002 + 1 and then performing arithmetic (12 divide by 10 divide by 2002
add 1).

So try  

  CDate([Forms]![Dated Report Selection]![Text3]) + 1

Or
  DateAdd("d",1,[Forms]![Dated Report Selection]![Text3])

Or
  DateAdd("d",1,CDate([Forms]![Dated Report Selection]![Text3]))

Quote:

> Hi,

> I have a problem with a SQL statement. Could anyone give
> me any suggestions why the problem occurs?

> Problem.
> I have a form with 2 unbound fields in it. They are for
> Start Date, the other for End Date. They are defaulted to:
> Start Date = Today - 30 days, End Date = Today. Simple so
> far. I then build the SQL statement to check a date field
> is either Greater than Start Date - 1 and Less then End
> Date + 1.

>         & "WHERE ((Incident.[Date of Incident]) > #" &
> ([Forms]![Dated Report Selection]![Text1] - 1) & "#" _
>         & "And (Incident.[Date of Incident]) < #" &
> ([Forms]![Dated Report Selection]![Text3] + 1) & "#);"

> This all works fine with default dates. I also have no
> problem if I change the start date. The SQL is correct and
> the resultant table is perfectly correct.

> However, if I change the End Date at all, I get an error:

>         Description:    Type Mismatch
>         Error Code      13

> Why can I do an arithmetic function on the Start Date - 1
> as well as an arithmetic function on End Date + 1 (when
> default) but when I change the date in End Date the
> arithmetic function will not work. It appears to be
> treating End Date once it has changed as a text string
> rather than a date.

> Does anyone have any suggestions that could rectify my
> problem?

> Neil



Tue, 03 May 2005 20:56:29 GMT  
 Type Mismatch Error 13
John,

Thanks, that worked just fine.

Neil

Quote:
>-----Original Message-----
>Not sure why you are having the problem, but you might

try using the DateAdd
Quote:
>function to calculate your dates. Or forcing the

control's value to be dates by
Quote:
>using CDate around them.  I suspect that Access (VBA) is

seeing something like
Quote:
> 12/10/2002 + 1 and then performing arithmetic (12 divide

by 10 divide by 2002
Quote:
>add 1).

>So try  

>  CDate([Forms]![Dated Report Selection]![Text3]) + 1

>Or
>  DateAdd("d",1,[Forms]![Dated Report Selection]![Text3])

>Or
>  DateAdd("d",1,CDate([Forms]![Dated Report Selection]!
[Text3]))


>> Hi,

>> I have a problem with a SQL statement. Could anyone give
>> me any suggestions why the problem occurs?

>> Problem.
>> I have a form with 2 unbound fields in it. They are for
>> Start Date, the other for End Date. They are defaulted
to:
>> Start Date = Today - 30 days, End Date = Today. Simple
so
>> far. I then build the SQL statement to check a date
field
>> is either Greater than Start Date - 1 and Less then End
>> Date + 1.

>>         & "WHERE ((Incident.[Date of Incident]) > #" &
>> ([Forms]![Dated Report Selection]![Text1] - 1) & "#" _
>>         & "And (Incident.[Date of Incident]) < #" &
>> ([Forms]![Dated Report Selection]![Text3] + 1) & "#);"

>> This all works fine with default dates. I also have no
>> problem if I change the start date. The SQL is correct
and
>> the resultant table is perfectly correct.

>> However, if I change the End Date at all, I get an
error:

>>         Description:    Type Mismatch
>>         Error Code      13

>> Why can I do an arithmetic function on the Start Date -
1
>> as well as an arithmetic function on End Date + 1 (when
>> default) but when I change the date in End Date the
>> arithmetic function will not work. It appears to be
>> treating End Date once it has changed as a text string
>> rather than a date.

>> Does anyone have any suggestions that could rectify my
>> problem?

>> Neil
>.



Fri, 06 May 2005 16:23:36 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Using CurrentDB() receives Type Mismatch Error 13

2. Type mismatch error 13?

3. Type Mismatch error 13

4. Help!!! Please, Type Mismatch error 13

5. Type mismatch error 13?

6. Type Mismatch Error 13

7. Passing a Recordset to function gives Type mismatch (error 13)

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

9. Error 13: Type Mismatch error

10. Type Mismatch Run-Time error 13

11. type mismatch error '13'????

12. Type mismatch, run-time error #13

 

 
Powered by phpBB® Forum Software