Subject: data type mismatch
Posted By: karma Post Date: 4/5/2006 11:14:14 AM
Hi

Can someone please help,I am having trouble creating a query.

I had a problem with two tables, one of them is linked from another database and only contains the first half of our unique number (before the full stop)

The other table contains a unique number in the format 06PG32.150203

With help, the following Expressions were used in a query in the table containing our unique number "Study_Number"

Expr1: InStr(1,[Variables]![Study_Number],".",0)
Expr2: Left([Variables]![Study_Number],[Expr1]-1)

Expr2 now shows only the first half of the Study_Number, but when I use it to try to make a join it keeps coming back with the data type mismatch message. I've gone through all the data and am convinced that it has something to do with the Expr2 field.

Does anyone have any suggestions how to fix this.

Thanks



Reply By: milind.paralkar Reply Date: 4/5/2006 11:46:35 PM
I think INSTR() of mysql takes only 2 arguments...

INSTR(str,substr)
    Returns the position of the first occurrence of substring substr in string str.
example:-

SELECT INSTR('foobarbar', 'bar');  --will return  
-> 4

check your expr1. I am sure about 'where clause' using 'instr function', they worked properly (for me).

Regards
Milind

Reply By: mat41 Reply Date: 4/5/2006 11:55:18 PM
mmmmm im confused.  This is the SQL area, one would think you are refering to an SQL function, are you?.  I am not aware of an SQL inStr function, however:

InStr is a VBScript function (yes it does take 4 argument however two of them are optional:

InStr([start, ]string1, string2[, compare])

Additionaly, I believe Left is a function in both languages:

LEFT (character_expression , integer_expression)
Returns the left part of a character string with the specified number of characters.

BTW if you want the SQL equivalent of inStr you may want to use:

SUBSTRING:
Returns part of a character, binary, text, or image expression.

Syntax
SUBSTRING ( expression , start , length )




Wind is your friend
Matt
Reply By: karma Reply Date: 4/6/2006 7:58:09 AM
thanks for all your suggestions,

Finally managed to get it to work, the problem was the data in the StudyNumber field (some didnt include a full stop and some were blank). Not much fun wading through thousands of records, but at least it's working now :)


Go to topic 38220

Return to index page 321
Return to index page 320
Return to index page 319
Return to index page 318
Return to index page 317
Return to index page 316
Return to index page 315
Return to index page 314
Return to index page 313
Return to index page 312