Code Question

Z

z03wpd

I need some help with a code. I've designed a query that adds a "FileAs"
column. The code for the column is as follows:
FileAs:
IIf(IsNull([FirstName]),IIf(IsNull([LastName]),[LastName]),IIf(IsNull([FirstName]),[LastName],[FirstName] & " " & [LastName]))

My question is how do I also include a MiddleInitial that is included in
the table design?
 
R

Rick Brandt

z03wpd said:
I need some help with a code. I've designed a query that adds a
"FileAs"
column. The code for the column is as follows:
FileAs:
IIf(IsNull([FirstName]),IIf(IsNull([LastName]),[LastName]),IIf(IsNull([FirstName]),[LastName],[FirstName]
& " " & [LastName]))

My question is how do I also include a MiddleInitial that is
included in
the table design?

First off, use Is Null in queries rather then the VBA IsNull() function. No
need to invoke a VBA functon when there is a SQL way to accomplish the same
thing.

Second, I can't make heads or tails of what you are trying to accomplish here.
In plain english what result do you want to achieve? Perhaps all you need is...

FileAs: (FirstName + " ") & (MidInitial + " ") & LastName
 
Z

z03wpd

Rick Brandt said:
z03wpd said:
I need some help with a code. I've designed a query that adds a
"FileAs"
column. The code for the column is as follows:
FileAs:
IIf(IsNull([FirstName]),IIf(IsNull([LastName]),[LastName]),IIf(IsNull([FirstName]),[LastName],[FirstName]
& " " & [LastName]))

My question is how do I also include a MiddleInitial that is
included in
the table design?

First off, use Is Null in queries rather then the VBA IsNull() function. No
need to invoke a VBA functon when there is a SQL way to accomplish the same
thing.

Second, I can't make heads or tails of what you are trying to accomplish here.
In plain english what result do you want to achieve? Perhaps all you need is...

FileAs: (FirstName + " ") & (MidInitial + " ") & LastName


--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com

I am attempting to design a database for my travel agency (I am an Independant Travel Agent). I want to use the database to gather client information via forms and then apply this information to a reservation that will be printed out and faxed to my home office. I looked at the Northwind database example and liked the "customer details form" and am trying to apply this form to my database. I designed the query with the above mentioned FileAs column. I want to combine the FirstName, MiddleInitial, and LastName columns to create the FileAs column. I then want to have the Auto_Title to show what's in the FileAs column.
I hope this fully explains what I am trying to do.
I will see if your suggestion works for me. Thank You.
 

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

Similar Threads

Concatenate FullName based on whether a field is empty. 8
How do I get IIf(IsNull.... to work?? 3
Combo Box 2
DLookUp or SELECT 2
Names Parse 1
Query 2
Concatenate 6
formula 1

Top