Sorry for the play by play, but now, an error says "The syntax of the
subqurey in this expression is incorrect. Check the subquery syntax
and
enclose the subquery in parentheses.
:
That's not what I wrote. It should be
SELECT Split([FirstName],"&")(0) & " " & [LastName]
That uses the Split function on the [FirstName] field to break the
field
every ampersand:
Split([FirstName],"&")
Even if there are no ampersands in the field, there should still be a
first
element of the returned array
Split([FirstName],"&")(0)
I concatenate that value with a space and the last name.
For the other name, I again use the Split function, but now I want to
make
sure that there are 2 separate names found
IIf(UBound(Split([FirstName], "&") = 1,
if there are 2 names, take the 1st name (remember that arrays returned
by
Split start at element 0)
Split([FirstName], "&")(1)
If there aren't 2 names, I return Null
Using + as the concatenation operator means that Split([FirstName],
"&")(1)
+ " " + [LastName] will return a complete name, while Null + " " +
[LastName] returns Null.
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
I have: FirstOwnerName:SELECT Split([FirstName],(0) "&") & " " &
[LastName]
What is the expression in this?
:
Untested air-code
SELECT Split([FirstName], "&")(0) & " " & [LastName] As Person1,
IIf(UBound(Split([FirstName], "&") = 1, Split([FirstName], "&")(1),
Null)
+
" " + [LastName] As Person2
FROM MyTable
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
On a related subject...Both husband and wife's names are in the
FirstName
field and their common last name is in the LastName field. For
most
reports
this is good. I'd like to make a query, though displaying the
husband's
first name, space " " last name as query field, then the wife's
first
name
(if there is a wife), " " wife's last name as a query field, so
that
they
can
be separated for signatures of each. Is this possible? Right
now, a
first
name example looks like this: "John L. & Jane M." The
cooresponding
last
name might look like this "Doe." The "&" sign is always part of
the
first
name, if there are two names.
:
On 15 Jan 2007 19:28:59 -0800, "CompGeek78"
<
[email protected]>
wrote:
Slight error in the formula there John.
Thanks... off the top of my head and I didn't check it!
John W. Vinson[MVP]