Will this expression return first word in string?

  • Thread starter Thread starter Cheryl Fischer
  • Start date Start date
C

Cheryl Fischer

This might work better:

Left([NodeName], InStr([NodeName], " ") -1)

In the expression you supplied, you were passing a literal instead of a
field name and also searching for a null string, "", rather than " "
 
Left("NodeName",InStr("NodeName","")-1)


I am using it as criteria in a select query under field "NodeName." The
column (NodeName) has multiword text strings and I need the first word only.

When I run it, I get no records back, even if this is the only field. If
there is a problem, can I ask how to rewrite this? Thanks.

Nick
 
Hi and thanks for helping. No luck. I'm still getting an "invalid
procedure call" error as I did earlier. I set this as criteria for the
column I want to trim down.

Nick


Cheryl Fischer said:
This might work better:

Left([NodeName], InStr([NodeName], " ") -1)

In the expression you supplied, you were passing a literal instead of a
field name and also searching for a null string, "", rather than " "



--
Cheryl Fischer
Law/Sys Associates
Houston, TX

Nick Mirro said:
Left("NodeName",InStr("NodeName","")-1)


I am using it as criteria in a select query under field "NodeName." The
column (NodeName) has multiword text strings and I need the first word only.

When I run it, I get no records back, even if this is the only field. If
there is a problem, can I ask how to rewrite this? Thanks.

Nick
 
If you're running this in as VBA code then you need a recordset reference

If you're running this as a query then you've posted to the wrong list, but
Left([NodeName],InStr([NodeName]," ")-1)
Will work everytime as long as you have at least one space in the field.

Hope this helps, Graeme.
 
Nick,

Putting the expression in the criteria is the wrong place! Put this expression
in an empty field in your query:

FirstWord:Left([NodeName], InStr([NodeName], " ") -1)


--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
(e-mail address removed)
www.pcdatasheet.com


Nick Mirro said:
Hi and thanks for helping. No luck. I'm still getting an "invalid
procedure call" error as I did earlier. I set this as criteria for the
column I want to trim down.

Nick


Cheryl Fischer said:
This might work better:

Left([NodeName], InStr([NodeName], " ") -1)

In the expression you supplied, you were passing a literal instead of a
field name and also searching for a null string, "", rather than " "



--
Cheryl Fischer
Law/Sys Associates
Houston, TX

Nick Mirro said:
Left("NodeName",InStr("NodeName","")-1)


I am using it as criteria in a select query under field "NodeName." The
column (NodeName) has multiword text strings and I need the first word only.

When I run it, I get no records back, even if this is the only field. If
there is a problem, can I ask how to rewrite this? Thanks.

Nick
 
If you are using this in an Update Query, it should go on the Update to:
row, rather than the Criteria row.

--
Cheryl Fischer
Law/Sys Associates
Houston, TX

Nick Mirro said:
Hi and thanks for helping. No luck. I'm still getting an "invalid
procedure call" error as I did earlier. I set this as criteria for the
column I want to trim down.

Nick


Cheryl Fischer said:
This might work better:

Left([NodeName], InStr([NodeName], " ") -1)

In the expression you supplied, you were passing a literal instead of a
field name and also searching for a null string, "", rather than " "



--
Cheryl Fischer
Law/Sys Associates
Houston, TX

Nick Mirro said:
Left("NodeName",InStr("NodeName","")-1)


I am using it as criteria in a select query under field "NodeName." The
column (NodeName) has multiword text strings and I need the first word only.

When I run it, I get no records back, even if this is the only field. If
there is a problem, can I ask how to rewrite this? Thanks.

Nick
 
Back
Top