Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data MisMatch error 1

Status
Not open for further replies.

vbahelp07

Technical User
Oct 16, 2007
115
US
I do not know why i am now getting a data mismatch error

DB_UDF_IMH_ARTIST is a chartext field

Data in it are as such:
ABC
ABC.DEF

Code:
OriginalArtist: IIf(Len([DB_UDF_IMH_ARTIST]=3),[DB_UDF_IMH_ARTIST],Null)

what is wrong with my syntax?
 
My guess would be the use of Null, try

Code:
OriginalArtist: IIf(Len([DB_UDF_IMH_ARTIST]=3),[DB_UDF_IMH_ARTIST],"")
 
seriously i thought i tried that!

i was at my wits end!

thanks!

can you help me with another syntax question ...

i want the column to show only the results (sales) for when the transaction was between a date range and the release date of the items were in the same year.

so i have this so far ...
Code:
NetSales: IIf([SOTransDate] Between 1/1/2004 And 12/31/2004 And [ML_UDF_IMH_RELEASEDATE] Like "*04",[SOExtChargeAmount],0)

but all the data is coming up $0
 
There was a mis-placed ) in your first posting
OriginalArtist: IIf(Len([DB_UDF_IMH_ARTIST][red])[/red]=3[yellow])[/yellow],[DB_UDF_IMH_ARTIST],Null)

You must delimit dates with #. 1/1/2004 is 1 divided by 1 divided by 2004 which is a very small number. Also, if [ML_UDF_IMH_RELEASEDATE] is a date then don't compare it to a string. If you want to find the year of a date field, use the Year() function.

Duane MS Access MVP
 
wonder why it didn't beep at me indicating i was missing ")".

i could not see it, now i do. thank you for pointing the what seemed to be the obvious. :)


ah ... ok, i changed it to:
Code:
NetSales: Sum(IIf([SOTransDate] Between #1/1/2004# And #12/31/2004# And Format([ML_UDF_IMH_RELEASEDATE],"yy")="04",[SOExtChargeAmount],0))

it's beautiful! thanks again!
 
I would probably not convert your date to a string in order to compare it with another string. It's a minor point but I would use:
Code:
NetSales: Sum(IIf([SOTransDate] Between #1/1/2004# And #12/31/2004# And Year[ML_UDF_IMH_RELEASEDATE])=2004,[SOExtChargeAmount],0))
Or possibly
Code:
NetSales: Sum(Abs([SOTransDate] Between #1/1/2004# And #12/31/2004# And Year([ML_UDF_IMH_RELEASEDATE])=2004)*[SOExtChargeAmount])

Duane MS Access MVP
 
ah, ok. i did not know about the Year thing. the only way i knew how was what I showed.

the 2nd part, what is the *, doesn't that mean multiple??
 
what is the *"? multiplication operator.

Duane MS Access MVP
 
Duane,
btw - this did not work.

Year[ML_UDF_IMH_RELEASEDATE])=2004

so for now i went back to the Format([ML_UDF_IM_RELEASEDATE],"yy")="04")
 
unless it's a copy and paste error, you're missing a paren in the YEAR function:

Code:
Year[COLOR=red]([/color][ML_UDF_IMH_RELEASEDATE])=2004

Leslie

In an open world there's no need for windows and gates
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top