Data type mismatch text to expression search

  • Thread starter Thread starter Tal
  • Start date Start date
T

Tal

Hi all,

I am trying to search a query where the field is actual an expression
comprised of a subquery.
I am getting a type mismatch error. Here is the code:

strWhere = "([expClientMainName] LIKE "" * " & Me.txtClientSearch & "" * ")"

I'm not even sure if this is possible.
Many thanks for your help.
 
Have you added a breakpoint in the code so you can inspect the value in
"strWhere"?

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
Tal said:
Hi all,

I am trying to search a query where the field is actual an expression
comprised of a subquery.
I am getting a type mismatch error. Here is the code:

strWhere = "([expClientMainName] LIKE "" * " & Me.txtClientSearch &
"" * ")"
strWhere = "([expClientMainName] LIKE "" * " & Me.txtClientSearch & "*
"")"

Should do it. (I usually use single quote double quote)
You can always run the string through a msgbox and see where the quotes
fall.
 
Mike Painter said:
Tal said:
Hi all,

I am trying to search a query where the field is actual an expression
comprised of a subquery.
I am getting a type mismatch error. Here is the code:

strWhere = "([expClientMainName] LIKE "" * " & Me.txtClientSearch &
"" * ")"
strWhere = "([expClientMainName] LIKE "" * " & Me.txtClientSearch & "*
"")"

Should do it. (I usually use single quote double quote)
You can always run the string through a msgbox and see where the quotes
fall.

Of course, the spaces around the asterisks shouldn't be there.
 
Hi Jeff,

I'm not sure I know what a breakpoint is. Can you please be more explicit.
Many thanks.
Tal

Jeff Boyce said:
Have you added a breakpoint in the code so you can inspect the value in
"strWhere"?

Regards

Jeff Boyce
Microsoft Office/Access MVP

Tal said:
Hi all,

I am trying to search a query where the field is actual an expression
comprised of a subquery.
I am getting a type mismatch error. Here is the code:

strWhere = "([expClientMainName] LIKE "" * " & Me.txtClientSearch & "" *
")"

I'm not even sure if this is possible.
Many thanks for your help.
 
Hi Douglas,

I keep removing the spaces and it keeps putting them back in automatically,
with the type mismatch error.
I am very much a newbie, so very explicit advise is very very useful.

Thanks,
Tal

Douglas J. Steele said:
Mike Painter said:
Tal said:
Hi all,

I am trying to search a query where the field is actual an expression
comprised of a subquery.
I am getting a type mismatch error. Here is the code:

strWhere = "([expClientMainName] LIKE "" * " & Me.txtClientSearch &
"" * ")"
strWhere = "([expClientMainName] LIKE "" * " & Me.txtClientSearch & "*
"")"

Should do it. (I usually use single quote double quote)
You can always run the string through a msgbox and see where the quotes
fall.

Of course, the spaces around the asterisks shouldn't be there.
 
Tal

You'll need to familiarize yourself with Visual Basic for Applications if
you are going to use a breakpoint.

The topic could probably fill 1-2 hours of classroom instruction, more time
than I can devote in this (volunteer) newsgroup.

I'd suggest opening the VBA window from Access and using HELP to learn more.

Good luck!

Regards

Jeff Boyce
Microsoft Office/Access MVP

Tal said:
Hi Jeff,

I'm not sure I know what a breakpoint is. Can you please be more
explicit.
Many thanks.
Tal

Jeff Boyce said:
Have you added a breakpoint in the code so you can inspect the value in
"strWhere"?

Regards

Jeff Boyce
Microsoft Office/Access MVP

Tal said:
Hi all,

I am trying to search a query where the field is actual an expression
comprised of a subquery.
I am getting a type mismatch error. Here is the code:

strWhere = "([expClientMainName] LIKE "" * " & Me.txtClientSearch & ""
*
")"

I'm not even sure if this is possible.
Many thanks for your help.
 
For anyone still following this thread.
I changed the String to a Variant and it worked.
Does this make sense?
Tal

Tal said:
Hi Douglas,

I keep removing the spaces and it keeps putting them back in automatically,
with the type mismatch error.
I am very much a newbie, so very explicit advise is very very useful.

Thanks,
Tal

Douglas J. Steele said:
Mike Painter said:
Tal wrote:
Hi all,

I am trying to search a query where the field is actual an expression
comprised of a subquery.
I am getting a type mismatch error. Here is the code:

strWhere = "([expClientMainName] LIKE "" * " & Me.txtClientSearch &
"" * ")"

strWhere = "([expClientMainName] LIKE "" * " & Me.txtClientSearch & "*
"")"

Should do it. (I usually use single quote double quote)
You can always run the string through a msgbox and see where the quotes
fall.

Of course, the spaces around the asterisks shouldn't be there.
 
Tal

Is there a chance your underlying table contains Nulls in that field?

Regards

Jeff Boyce
Microsoft Office/Access MVP

Tal said:
For anyone still following this thread.
I changed the String to a Variant and it worked.
Does this make sense?
Tal

Tal said:
Hi Douglas,

I keep removing the spaces and it keeps putting them back in
automatically,
with the type mismatch error.
I am very much a newbie, so very explicit advise is very very useful.

Thanks,
Tal

Douglas J. Steele said:
Tal wrote:
Hi all,

I am trying to search a query where the field is actual an
expression
comprised of a subquery.
I am getting a type mismatch error. Here is the code:

strWhere = "([expClientMainName] LIKE "" * " & Me.txtClientSearch &
"" * ")"

strWhere = "([expClientMainName] LIKE "" * " & Me.txtClientSearch &
"*
"")"

Should do it. (I usually use single quote double quote)
You can always run the string through a msgbox and see where the
quotes
fall.

Of course, the spaces around the asterisks shouldn't be there.
 
Yup! Would that affect whether it ought to be a string or a variant?

I will include an If Null option, but I didn't think that could affect a
type mismatch error?

Interesting.

Jeff Boyce said:
Tal

Is there a chance your underlying table contains Nulls in that field?

Regards

Jeff Boyce
Microsoft Office/Access MVP

Tal said:
For anyone still following this thread.
I changed the String to a Variant and it worked.
Does this make sense?
Tal

Tal said:
Hi Douglas,

I keep removing the spaces and it keeps putting them back in
automatically,
with the type mismatch error.
I am very much a newbie, so very explicit advise is very very useful.

Thanks,
Tal

:

Tal wrote:
Hi all,

I am trying to search a query where the field is actual an
expression
comprised of a subquery.
I am getting a type mismatch error. Here is the code:

strWhere = "([expClientMainName] LIKE "" * " & Me.txtClientSearch &
"" * ")"

strWhere = "([expClientMainName] LIKE "" * " & Me.txtClientSearch &
"*
"")"

Should do it. (I usually use single quote double quote)
You can always run the string through a msgbox and see where the
quotes
fall.

Of course, the spaces around the asterisks shouldn't be there.
 
If I recall correctly, "strings" don't do Nulls. Variants handle nulls,
though...

Regards

Jeff Boyce
Microsoft Office/Access MVP


Tal said:
Yup! Would that affect whether it ought to be a string or a variant?

I will include an If Null option, but I didn't think that could affect a
type mismatch error?

Interesting.

Jeff Boyce said:
Tal

Is there a chance your underlying table contains Nulls in that field?

Regards

Jeff Boyce
Microsoft Office/Access MVP

Tal said:
For anyone still following this thread.
I changed the String to a Variant and it worked.
Does this make sense?
Tal

:

Hi Douglas,

I keep removing the spaces and it keeps putting them back in
automatically,
with the type mismatch error.
I am very much a newbie, so very explicit advise is very very useful.

Thanks,
Tal

:

Tal wrote:
Hi all,

I am trying to search a query where the field is actual an
expression
comprised of a subquery.
I am getting a type mismatch error. Here is the code:

strWhere = "([expClientMainName] LIKE "" * " & Me.txtClientSearch
&
"" * ")"

strWhere = "([expClientMainName] LIKE "" * " & Me.txtClientSearch
&
"*
"")"

Should do it. (I usually use single quote double quote)
You can always run the string through a msgbox and see where the
quotes
fall.

Of course, the spaces around the asterisks shouldn't be there.
 
Back
Top