Data type mismatch text to expression search

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.
 
J

Jeff Boyce

Have you added a breakpoint in the code so you can inspect the value in
"strWhere"?

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
M

Mike Painter

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.
 
D

Douglas J. Steele

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.
 
T

Tal

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.
 
T

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

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.
 
J

Jeff Boyce

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.
 
T

Tal

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.
 
J

Jeff Boyce

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.
 
T

Tal

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.
 
J

Jeff Boyce

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.
 

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