By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,660 Members | 1,133 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,660 IT Pros & Developers. It's quick & easy.

Type Mismatch Error... Really Stumped!!

P: n/a
Type Mismatch error

I recieve a type mismatch error on the following line of code which is
based on a specific date. It does NOT break on all records only
"some". The dates for the records that ARE breaking are no different
then the ones that are NOT breaking... Any hely is appreciated...

Mike

CODE:

Me.Driver_Years_Driving = Nz(DateDiff("yyyy", [DOCD], Date) -
IIf(Format(Date, "mmdd") < Format([DOCD], "mmdd"), 1, 0), "0")

Aug 9 '07 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Presumably the Driver_Years_Driving field is a Number field (not a Text
field.)

You are calculating a numeric value.
You wrapped the result in Nz(), to convert a null into a *string*.
Try without the quotes around the zero, so the result is a numeric value:

Me.Driver_Years_Driving = Nz(DateDiff("yyyy", [DOCD], Date) - _
IIf(Format(Date, "mmdd") < Format([DOCD], "mmdd"), 1, 0), 0)
--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Mike" <in**@baltworld.comwrote in message
news:11**********************@k79g2000hse.googlegr oups.com...
Type Mismatch error

I recieve a type mismatch error on the following line of code which is
based on a specific date. It does NOT break on all records only
"some". The dates for the records that ARE breaking are no different
then the ones that are NOT breaking... Any hely is appreciated...

Mike

CODE:

Me.Driver_Years_Driving = Nz(DateDiff("yyyy", [DOCD], Date) -
IIf(Format(Date, "mmdd") < Format([DOCD], "mmdd"), 1, 0), "0")
Aug 9 '07 #2

P: n/a
Mike wrote:
Type Mismatch error

I recieve a type mismatch error on the following line of code which is
based on a specific date. It does NOT break on all records only
"some". The dates for the records that ARE breaking are no different
then the ones that are NOT breaking... Any hely is appreciated...

Mike

CODE:

Me.Driver_Years_Driving = Nz(DateDiff("yyyy", [DOCD], Date) -
IIf(Format(Date, "mmdd") < Format([DOCD], "mmdd"), 1, 0), "0")
Instead of "0" use 0. I'll assume Me.Driver_Years_Driving is a numeric
field.
Aug 9 '07 #3

P: n/a
On Aug 9, 9:45 am, Salad <o...@vinegar.comwrote:
Mike wrote:
Type Mismatch error
I recieve a type mismatch error on the following line of code which is
based on a specific date. It does NOT break on all records only
"some". The dates for the records that ARE breaking are no different
then the ones that are NOT breaking... Any hely is appreciated...
Mike
CODE:
Me.Driver_Years_Driving = Nz(DateDiff("yyyy", [DOCD], Date) -
IIf(Format(Date, "mmdd") < Format([DOCD], "mmdd"), 1, 0), "0")

Instead of "0" use 0. I'll assume Me.Driver_Years_Driving is a numeric
field.
OK.. All is correct based on both points of direction, however it
still breaks. The problem that I find is that the DOCD is null and
therefor the string does not execute?? Any Ideas??

Mike

Aug 9 '07 #4

P: n/a
On Aug 9, 9:33 am, "Allen Browne" <AllenBro...@SeeSig.Invalidwrote:
Presumably the Driver_Years_Driving field is a Number field (not a Text
field.)

You are calculating a numeric value.
You wrapped the result in Nz(), to convert a null into a *string*.
Try without the quotes around the zero, so the result is a numeric value:

Me.Driver_Years_Driving = Nz(DateDiff("yyyy", [DOCD], Date) - _
IIf(Format(Date, "mmdd") < Format([DOCD], "mmdd"), 1, 0), 0)
--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users -http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Mike" <i...@baltworld.comwrote in message

news:11**********************@k79g2000hse.googlegr oups.com...
Type Mismatch error
I recieve a type mismatch error on the following line of code which is
based on a specific date. It does NOT break on all records only
"some". The dates for the records that ARE breaking are no different
then the ones that are NOT breaking... Any hely is appreciated...
Mike
CODE:
Me.Driver_Years_Driving = Nz(DateDiff("yyyy", [DOCD], Date) -
IIf(Format(Date, "mmdd") < Format([DOCD], "mmdd"), 1, 0), "0")- Hide quoted text -

- Show quoted text -
OK.. All is correct based on both points of direction, however it
still breaks. The problem that I find is that the DOCD is null and
therefor the string does not execute?? Any Ideas??

Mike

Aug 9 '07 #5

P: n/a
Mike wrote:
On Aug 9, 9:45 am, Salad <o...@vinegar.comwrote:
>>Mike wrote:
>>>Type Mismatch error
>>>I recieve a type mismatch error on the following line of code which is
based on a specific date. It does NOT break on all records only
"some". The dates for the records that ARE breaking are no different
then the ones that are NOT breaking... Any hely is appreciated...
>>>Mike
>>>CODE:
>>>Me.Driver_Years_Driving = Nz(DateDiff("yyyy", [DOCD], Date) -
IIf(Format(Date, "mmdd") < Format([DOCD], "mmdd"), 1, 0), "0")

Instead of "0" use 0. I'll assume Me.Driver_Years_Driving is a numeric
field.


OK.. All is correct based on both points of direction, however it
still breaks. The problem that I find is that the DOCD is null and
therefor the string does not execute?? Any Ideas??

Mike
Sure.
If Not IsNull(Me.Docd) then
Me.Driver_Years_Driving = Nz(DateDiff("yyyy", [DOCD], Date) -
IIf(Format(Date, "mmdd") < Format([DOCD], "mmdd"), 1, 0), "0")
Else
Me.Driver_Years_Driving = 0
Endif
Aug 9 '07 #6

P: n/a
If DOCD is Null, then
Format([DOCD], "mmdd")
returns a zero-length string, which is not less than "0809", so the Else
executes, and subtracts zero from Null, yielding Null. Then Nz() then
converts that to zero.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Mike" <in**@baltworld.comwrote in message
news:11**********************@r34g2000hsd.googlegr oups.com...
On Aug 9, 9:33 am, "Allen Browne" <AllenBro...@SeeSig.Invalidwrote:
>Presumably the Driver_Years_Driving field is a Number field (not a Text
field.)

You are calculating a numeric value.
You wrapped the result in Nz(), to convert a null into a *string*.
Try without the quotes around the zero, so the result is a numeric value:

Me.Driver_Years_Driving = Nz(DateDiff("yyyy", [DOCD], Date) - _
IIf(Format(Date, "mmdd") < Format([DOCD], "mmdd"), 1, 0), 0)

"Mike" <i...@baltworld.comwrote in message

news:11**********************@k79g2000hse.googleg roups.com...
Type Mismatch error
I recieve a type mismatch error on the following line of code which is
based on a specific date. It does NOT break on all records only
"some". The dates for the records that ARE breaking are no different
then the ones that are NOT breaking... Any hely is appreciated...
Mike
CODE:
Me.Driver_Years_Driving = Nz(DateDiff("yyyy", [DOCD], Date) -
IIf(Format(Date, "mmdd") < Format([DOCD], "mmdd"), 1, 0), "0")- Hide
quoted text -

- Show quoted text -

OK.. All is correct based on both points of direction, however it
still breaks. The problem that I find is that the DOCD is null and
therefor the string does not execute?? Any Ideas??

Mike
Aug 9 '07 #7

P: n/a
On Aug 9, 11:20 am, "Allen Browne" <AllenBro...@SeeSig.Invalidwrote:
If DOCD is Null, then
Format([DOCD], "mmdd")
returns a zero-length string, which is not less than "0809", so the Else
executes, and subtracts zero from Null, yielding Null. Then Nz() then
converts that to zero.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users -http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Mike" <i...@baltworld.comwrote in message

news:11**********************@r34g2000hsd.googlegr oups.com...
On Aug 9, 9:33 am, "Allen Browne" <AllenBro...@SeeSig.Invalidwrote:
Presumably the Driver_Years_Driving field is a Number field (not a Text
field.)
You are calculating a numeric value.
You wrapped the result in Nz(), to convert a null into a *string*.
Try without the quotes around the zero, so the result is a numeric value:
Me.Driver_Years_Driving = Nz(DateDiff("yyyy", [DOCD], Date) - _
IIf(Format(Date, "mmdd") < Format([DOCD], "mmdd"), 1, 0), 0)
"Mike" <i...@baltworld.comwrote in message
>news:11**********************@k79g2000hse.googleg roups.com...
Type Mismatch error
I recieve a type mismatch error on the following line of code which is
based on a specific date. It does NOT break on all records only
"some". The dates for the records that ARE breaking are no different
then the ones that are NOT breaking... Any hely is appreciated...
Mike
CODE:
Me.Driver_Years_Driving = Nz(DateDiff("yyyy", [DOCD], Date) -
IIf(Format(Date, "mmdd") < Format([DOCD], "mmdd"), 1, 0), "0")- Hide
quoted text -
- Show quoted text -
OK.. All is correct based on both points of direction, however it
still breaks. The problem that I find is that the DOCD is null and
therefor the string does not execute?? Any Ideas??
Mike- Hide quoted text -

- Show quoted text -
Thanks to all the problem is solved, I have allowed for null and the
system now works fine. The biggest problem was that I had my column
count listed at 20 and the DODC value populated on 21... Duh!!!

Thanks Much for all of the assistance.

Mike

Aug 9 '07 #8

This discussion thread is closed

Replies have been disabled for this discussion.