Type Mismatch

M

Mark A. Sam

In the following code,

If IsNull([Year]) Or [Year] = "" Then
[Year] = Year(Date)
Else
[Year] = [Year] + 1
End If

I get Runtime Error 13, Type Mismatch, which refers to the function,

Year(Date)

Executing this in the immediate window, ?Year(Date) returns 2005.

I don't know what could be causing this. I ruled out the field name [Year]
as being the problem. Thanks for any help.

God Bless,

Mark A. Sam
 
B

Brendan Reynolds

Well, rule it back in again, because that is exactly what the problem is. If
you need proof, try this ...

Private Sub Command8_Click()

If IsNull([Year]) Or [Year] = "" Then
[Year] = VBA.Year(Date)
Else
[Year] = [Year] + 1
End If

End Sub
 
R

RuralGuy

Mark A. Sam said:
In the following code,

If IsNull([Year]) Or [Year] = "" Then
[Year] = Year(Date)
Else
[Year] = [Year] + 1
End If

I get Runtime Error 13, Type Mismatch, which refers to the function,

Year(Date)

Executing this in the immediate window, ?Year(Date) returns 2005.

I don't know what could be causing this. I ruled out the field name
[Year] as being the problem. Thanks for any help.

God Bless,

Mark A. Sam

Mark, this is different than your post at 1:29 today. Which one are we
troubleshooting?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top