PC Review


Reply
Thread Tools Rate Thread

I keep getting error code 13 - Type Mismatch

 
 
=?Utf-8?B?VE9NSw==?=
Guest
Posts: n/a
 
      21st Dec 2004
I am trying to use the "Year( #1/1/2005#)" Function where I replace the
"#1/1/2005#" value with a variable that is a date entered into a field called
[Start]. I have tried to define this variable as integer and and just about
every other data type there is, but I keep getting the "Type Mismatch"
message. the code looks like
Dim StartYear As Date
Dim x As Integer

StartYear = [Start] '[Start] is a "Date/Time" field
MsgBox ("StartYear = " & StartYear)
x = Year(StartYear)
MsgBox ("X is " & x)

I don't know what I am doing incorrectly, but for some reason I can't get
the thing to work.

Any help would be appreciated.
--
Tomk
 
Reply With Quote
 
 
 
 
Paul Overway
Guest
Posts: n/a
 
      21st Dec 2004
Is [Start] null? If it is, that is the problem.

--
Paul Overway
Logico Solutions
http://www.logico-solutions.com


"TOMK" <(E-Mail Removed)> wrote in message
news:091283DD-E7F4-40C2-A4A3-(E-Mail Removed)...
>I am trying to use the "Year( #1/1/2005#)" Function where I replace the
> "#1/1/2005#" value with a variable that is a date entered into a field
> called
> [Start]. I have tried to define this variable as integer and and just
> about
> every other data type there is, but I keep getting the "Type Mismatch"
> message. the code looks like
> Dim StartYear As Date
> Dim x As Integer
>
> StartYear = [Start] '[Start] is a "Date/Time" field
> MsgBox ("StartYear = " & StartYear)
> x = Year(StartYear)
> MsgBox ("X is " & x)
>
> I don't know what I am doing incorrectly, but for some reason I can't get
> the thing to work.
>
> Any help would be appreciated.
> --
> Tomk



 
Reply With Quote
 
 
 
 
=?Utf-8?B?S2VuIFdhcnRoZW4=?=
Guest
Posts: n/a
 
      21st Dec 2004
You could create a funtion to return the year portion of whatever date is
passed from your START field. You might try something like the following.

Public Function CalculateYear(Start As Date) As Integer
Dim x As Integer
x = Year([Start]) '[Start] is a "Date/Time" field)
MsgBox ("StartYear = " & x)
MsgBox ("X is " & x)
CalculateYear = x
End Function


"TOMK" wrote:

> I am trying to use the "Year( #1/1/2005#)" Function where I replace the
> "#1/1/2005#" value with a variable that is a date entered into a field called
> [Start]. I have tried to define this variable as integer and and just about
> every other data type there is, but I keep getting the "Type Mismatch"
> message. the code looks like
> Dim StartYear As Date
> Dim x As Integer
>
> StartYear = [Start] '[Start] is a "Date/Time" field
> MsgBox ("StartYear = " & StartYear)
> x = Year(StartYear)
> MsgBox ("X is " & x)
>
> I don't know what I am doing incorrectly, but for some reason I can't get
> the thing to work.
>
> Any help would be appreciated.
> --
> Tomk

 
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
Keep getting "Type mismatch" Philosophaie Microsoft Excel Programming 11 27th Mar 2010 09:50 PM
keep getting type mismatch error vbidiot Microsoft Excel Programming 4 15th Feb 2006 09:42 PM
Help: Compile error: type mismatch: array or user defined type expected lvcha.gouqizi Microsoft Excel Programming 1 31st Oct 2005 09:20 PM
Getting a type mismatch error when trying to run code John Microsoft Access Form Coding 1 4th May 2004 08:43 PM
Type mismatch error (different than previous type mismatch?) Roberta Microsoft Access VBA Modules 3 9th Jan 2004 07:26 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:35 PM.