Field with both first name and last name

I have a table where the field PRODUCTION_DESIGNER is composed of a persons 
first and last name with a single space between them, for example "David 
Henderson" is in the contents.  Select this field and truncate this to the 
initials of the first and last name and place into another field leaving the 
original field untouched.  The new field would have "DH" as its contents.

Thank you

0
Utf
1/9/2008 4:34:00 PM
access.queries 6343 articles. 1 followers. Follow

2 Replies
878 Views

Similar Articles

[PageSpeed] 46

Use the expression

Left(Production_Designer,1) & 
Mid(Production_Designer,Instr(Production_Designer," ")+1,1)

If you want to do this in an update query

UPDATE [Your Table Name]
SET [Initials] = Left([Production_Designer],1) & 
Mid([Production_Designer],Instr([Production_Designer]," ")+1,1)
WHERE Production_Designer is not null

NOTE: Backup your data first.  That way if this fails to do what you want 
you can set the data back to its original state and try something else.
-- 
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
..

"THINKINGWAY" <THINKINGWAY@discussions.microsoft.com> wrote in message 
news:9C71AF9E-65E2-4496-82A2-07FB2A60F33E@microsoft.com...
>I have a table where the field PRODUCTION_DESIGNER is composed of a persons
> first and last name with a single space between them, for example "David
> Henderson" is in the contents.  Select this field and truncate this to the
> initials of the first and last name and place into another field leaving 
> the
> original field untouched.  The new field would have "DH" as its contents.
>
> Thank you
> 


0
John
1/9/2008 5:01:18 PM
The only problem with John's solution is that it assumes that none of the 
values in your [PRODUCTION_DESIGNER] field contain NULLs, and that every 
record contains a space.

If you are absolutely sure that every record has a first and last name, 
separated by a space, great.  But if you are not absolutely sure, then you 
might want to write a function that you can pass a variant (to handle NULL 
values) and then perform some tests on it before you return a value.

Then, you could call this function:

SELECT ..., fnInitials([Production_Designer]) as Initials
FROM yourTable

Public Function fnInitials(Byval SomeName as Variant) as string

    'Returns an empty string if SomeName is NULL or blank
    'If there is no space in the name, it returns a single letter
    'Otherwise, returns two characters
    SomeName = TRIM(SomeName & "")
    if LEN(SomeName) = 0 then
        Initials = ""
    elseif instr(SomeName, " ") = 0 then
        Initials = Left(SomeName, 1)
    elseif 
        Initials = Left(SomeName, 1) _
                   & Mid(SomeName, instr(SomeName, " ") + 1, 1)
    endif

End Function

HTH
Dale
-- 
Don''t forget to rate the post if it was helpful!

email address is invalid
Please reply to newsgroup only.



"THINKINGWAY" wrote:

> I have a table where the field PRODUCTION_DESIGNER is composed of a persons 
> first and last name with a single space between them, for example "David 
> Henderson" is in the contents.  Select this field and truncate this to the 
> initials of the first and last name and place into another field leaving the 
> original field untouched.  The new field would have "DH" as its contents.
> 
> Thank you
> 
0
Utf
1/9/2008 9:22:03 PM
Reply:

Similar Artilces:

validate a field based on sum of other fields
I have to assign commission to agents for each "order". I can have anywhere from 1 agent at 100% commission to 5 agents with every possible combination of percentages. Obviously, I need the percentage entries to only add up to 100 and I'd like to force the user to adjust the figures until they total 100. Firstly, am I right in assuming it would be better to be assigning the agents to the orderIDs in separate records: OrderID, Agent, Agent Percentage (as opposed to having one record contain the OrderID, Agent1, Agent1Percentage, Agent2, Agent2Percentage, Agent3, Agent3Pe...

Pivot Table Calculated field #3
I have a pivot table with columns for No's, Yes's and Grand Total. I would like to calculate the % of Yes's by dividing the Yes's by the Grand total. Can someone give me an easy explanation of how to do that or a source? I have tried every thing I can think of and the directions I have found have not helped.... Thanks, Ann To calculate total percent Yes, you could use the GETPIVOTDATA function in a formula outside the pivot table. For example: =GETPIVOTDATA("Region",$A$5,"Valid","Yes")/GETPIVOTDATA("Region",$A$5) MOE wrote: &g...

Locking Field position on screen.
I have created a simple form in Word 2007 with maybe 2 or 3 fields across and 3 or 4 fields down, but my problem is I would like to be able to lock the field positions in place on the screen. When I type in a field, the field to the left moves. I need to lock the position. Can this be done. Frank Most forms designers put form fields in table cells of a fixed dimension. -- Suzanne S. Barnhill Microsoft MVP (Word) Words into Type Fairhope, Alabama USA http://word.mvps.org "Francis Cunningham, Jr." <FrancisCunninghamJr@discussions.microsoft.com> wrote in m...

scripto to cut/paste to next field
Here is my situation: 1) A page on IE will be open, and I will have a cursor in a field on the page (field that has text in it) 2) I need to hit a shortcut (ctrl-shft-something) that cuts everything to the right of the cursor, advances a field (effectively, replicates ‘tab’ action), and pastes Anyone have some code (and instructions on what to do with the code) that may solve the above? -- Boris "BorisS" <BorisS@discussions.microsoft.com> wrote in message news:D4B54CE9-F2A4-4195-B2E3-ABA75A49202C@microsoft.com... > Here is my situation: > > 1...

Sendinng mail showing a different sender's name
Hi, At my work, we use Outlook 2000. I have my normal email mailbox address andre@companyname.com , but I also have access to another mailbox "info@companyname.com" When I send emails, the mesage always automatically shows the sender as "andre@companyname.com" Is there a way to set the default sender to "info@companyname.com " so that the receiver sees that name and not "andre". I do not want to individually modify each email sent using the "FROM" feature, as this would be time consuming. In my Outlook on my personnal computer, I know h...

Extracting a column from a named range
Dear all, I have named a range "Scores" across 3 sheets (i.e. Sheet1:Sheet3!$A$1:$B$10). How can I find the median of values in "Scores" in Sheet1 ONLY? I don't know how to provide the target range in the function MEDIAN(). Best Regards, Andy Chan On Sat, 24 Dec 2005 19:24:06 +0800, "Andy Chan" <chankhandy-msnewsgroup@yahoo.com.hk> wrote: >Dear all, > > I have named a range "Scores" across 3 sheets (i.e. >Sheet1:Sheet3!$A$1:$B$10). How can I find the median of values in "Scores" >in Sheet1 ONLY? I don...

When printing a contact the other field (Notes) get cut off
Version: 2008 Operating System: Mac OS X 10.5 (Leopard) Processor: Intel Email Client: Exchange Also when just viewing the contact in the address book. <br> I have tried this on two different macbook pro's and the issue is the same. Tried a different printer also. Please help On 3/10/10 12:47 PM, mwilshrie@officeformac.com wrote: > Also when just viewing the contact in the address book. I have tried > this on two different macbook pro's and the issue is the same. Tried > a different printer also. Please help Can you post a picture of what you're de...

text field to date field field
I have a database that has a text field called "visit" it has been filled with data ie., " 6/22/07 - not good, " the field may also be blank or it may contain random text after the date. In some cases no date at all just text. I would like to create a new field called DateVisit that contains just the dates that were entered in the field "visit" it has been a struggle and I have made no progress please help abbenj@verizon.net/nospam From your description, the field might contain a date, or a date and text, or text, or nothing. How would you explai...

Form Fields In Outlook Template
Help !!! I'm not a developer, just a user, but I need some help. What I want to do is create an Outlook 2003 template, that uses form fields (Text, drop down boxes, etc.....) However, it looks like to properly create an Outlook template, you cannot use Word as your editor. But if I do not use Word as the editor, then I cannot access the Form Toolbar. This cannot be a new request - but I just cannot seem to figure this out. Help !!! Thank you See my response to your other post on this issue.=20 --=20 Sue Mosher, Outlook MVP Author of Microsoft Outlook Programming - Jumpstart...

Select First(Field1) From Table1 Order By Field1
Hi I am trying to run a query in this format: - SELECT First([FM_InvoiceImport].[Field1]) AS FirstOfField1 FROM FM_InvoiceImport ORDER BY [FM_InvoiceImport].[Field1]; It keeps telling me 'You tried to execute a query that does not include the specified expression '[FM_InvoiceImport].[Field1]' as part of an aggregate function.' Why won't it work?? Stapes SELECT First(FM_InvoiceImport.Field1) AS FirstOfField1 FROM FM_InvoiceImport; or SELECT First(FM_InvoiceImport.Field1) AS FirstOfField1, FM_InvoiceImport.IDField FROM FM_InvoiceImport GROUP BY FM_InvoiceImport.ID...

Default fields in new fields
Using Outlook 2K When creating a new mail folder, it does not include the Subject and Received fields necessitating their having to be added every time. How can I get this to revert to the default fields? Thanks, Cathy ...

multiple critera for one field in a query
Hi, i am trying to get a count of a certain criteria but in different columns. Its hard to explain, but assume i have a table which consists of... A 550 B 600 C 20 A 100 C 75 B 120 D 390 Then in a query I am trying to have the result of: Over 500 Over 100 Over 25 Under 25 A 1 1 0 0 B 1 1 0 0 C 0 0 1 1 D 0 1 0 0 The way i have done...

required fields
Hello: Through either VBA or Modifier, is it possible to make a field that is required in Great plains by design to not be required but be optional instead? I doubt it. The best that I could come up with was to just have VBA fill the required field with a "dummy" piece of information and move on. Any other ideas? I suppose the only other way is through Dexterity. The field is the "Interview Range from 1 to" in the HR Interview Setup window. I just decided to have VBA fill it with "01". Thanks! childofthe1980s You are right, fields Required by GP cann...

Create Named Range for each unique value
Hi! All help is welcome here... Am really stuck. What I have is a list of room numbers. Many appear multiple times i column A, but it will always be sorted. What I need is a way to easily create Named Ranges for each group of rooms. (ie all rows with value 1 becomes one named range, rows with value 5 becomes one named range and so on) Range Name should prefereable be same a room name. Would like the code to go through column A and create ranges for each unique value. (could also have a "supporting" sheet with uniqe values if necessary) Any takers? If the valu...

IV00102 Fields
These four fields are set to zero when I create a new item and assign it to a location. However, when I look at the table descriptions zero is not a valid value for any of them. Are these four fields currently used for anything or are they there for future use? This currently is GP10 SP3. 1) IV00102.REPLENISHLEVEL 2) IV00102.POPVENDORSELECTION 3) IV00102.POPPRICINGSELECTION 4) IV00102.PICKTICKETITEMOPT Rich, Replenishment Level is the default replenishment level for POP Auto Generator. Values are 1, 2 and 3. 1 for Order point QTy, 2 for order upto level, 3 for vendor EoQ. If these fiel...

How do give each datapoint a separate name/label in a scatter char
I am attempting to graph job growth and absolute employment (x and y axis respectively) for 64 cities. How do I put the city name next to that data point. For example, Atlanta has averaged 1.6% job growth and 37,000 new jobs per year. 1.6% is the x axis value, 37,000 is the Y axis value, but I would like to label the data point "Atlanta". This allows me to compare Atlanta's growth with the other 63 cities. Please let me know if this is possible. Check out Rob Bovey's XY Chartlabeler (www.appspro.com) or John Walkenbach's Chart Tools (www.j-walk.com). -- Reg...

Field by Field Comparison
I have two tables with the exact same column names. I want to do a field by field comparison of the two tables. If one letter or number is off in any field, I would like for the whole record to show up in my query. I can only figure out how to show records which are equal. I would like to show records which are not equal. Is there a query criteria or something where I can perform this? Thanks. Do a UNION query. Create a query that lists all the field in one table. Then open that query in SQL view. At the end of the SQL, delete the semicolon ";". At the...

splitting a field into two fields; one in ()
I have a Name field in my database that is LastName,FirstName(dept). I have figured out how to split last name and first name but I don't know how to leave out the department name that is in () after the first name. Any suggestions? Quick and Dirty way to get the field down to just LastName,Firstname is to use the following as an expression in a query: LastFirst:Left([Name],Instr([Name],"(")-1) This should give you all of the characters to the left of the opening parenthesis. You could then apply your method for splitting the First and Last Names. HTH ...

Joining fields into one field dependent on value of another field
Hi, Below is a sample of data of a query which I need assistance in - Group Fertiliser ApplicationRate 1 TSP 3 2 EFB 230 3 Kies. 3 4 EFB 230 4 Kies. 3 5 TSP 3 5 Kies. 3 7 EFB 230 7 TSP 3 7 Kies. 3 >From this, I would like to create a field such that it shows eg. Group FertiliserDescription 1 TSP (3) 2 EFB (230) 3 Kies. (3) 4 EFB (230), Kies(3) 7 EFB(230),TSP(3),Kies(3) I am able to put Fertiliser and ApplicationRate together ie. Fertiliser& "(" &ApplicationRate& ")" My problem being how to add a statement saying th...

How to set color of field?
In ObjectPal I used the 'Arrive' event to set the color of a field or a record in a child table. This allowed the color to vary from one record to the next in a datasheet view. In Access, the 'On Current' event only works in form view. It doesn't work in datasheet view. The 'Format' event is only available in Report objects. The 'Conditional' format only allows three alternatives. How can Access vary colors from one record to the next in a datasheet, or datasheet-like view? "WDSnews" <wdsnews.0640@oregoncity.com> wrot...

Null Field to Interupt Closing
I am using this code to check for blank fields in BeforeUpdate: If NZ(Trim(Me!Date),vbnullstring) = vbnullstring then Msgbox "PLEASE ENTER DATE",,"Missing date" Me!Date.setfocus Cancel = True Exit Sub End if It almost works, except the form goes ahead and closes anyway. The user clicks the close button and the message box pops up if the field is empty, they click OK and instead of keeping the form open and then setting focus on the empty field, it closes the form. How can I get it to interupt the close and keep the form open? Thank you in advance for any...

Problem with after update code in field that disables another field
Hi I want to be able to disable the Non Member field in a record when something is entered in the Member field. Unfortunately, the code I am usng below disables the Non Member field in *all* records, and the database has to be closed and reopened to get round this before data entry can continue. I'd be grateful if someone could show me the correction, Thanks. Private Sub Member_AfterUpdate() If Not IsNull([Member]) Then Me![Non Members].Enabled = False Else Me![Non Members].Enabled = True End If End Sub Sam, You need to put that same code in on the OnCurrent event of the form...

Field name derived from a string value returns a Run-time error 2465.
I have two labels on a form and want to populate them during the run time of my form. The name of the labels are "1" the other is called "2" (without the quotes of course). Field 1 runs OK but two returns a run-time error 2465. Of course, the real form is much bigger. A lot of fields called 1 through 31 are populated from within a loop. To simplify my question I down sized this post to two label fields. Any one know how to solve the problem with label "2"? Any help or hint is appreciated. ' This works OK Me![1].Caption = "abc"...

Name of the Day
1. if I add one to the Date it gives me date of the next day. How do I do it for the days? Example: 04-Jan in cell A1, on A2 I have =A1+1 gives me 05-Jan if 'Sat' in B1, I want 'Sun' on B2 and so on. 2. if possible I would like to have the cell B1 to show name of the day on a date, If A1 has 04-Jan, I want B1 to show MON or Mon and so on. Thanks in Advance! In B1, use =a1 And custom format as ddd Regards, Fred "Raz" <Raz@discussions.microsoft.com> wrote in message news:42B95FB2-2BA1-4B48-9A0F-DDB340DC0068@microsoft.com... > 1....

ReportViewer
Using ReportViewer control v9 in .aspx page - When displaying date type parameter field in my report nothing happens when calendar icon is clicked (no calendar page, no error) in ie 8. FoxFire works. Same report works fine when viewed directly on the report server in ie8. Resolved myself. Sloppy coding on the Master page. <form> tag out of place in table structure. "Pete Hay" wrote: > Using ReportViewer control v9 in .aspx page - When displaying date type > parameter field in my report nothing happens when calendar icon is clicked > (no calen...