Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Get text before space in access

Posted on 2009-04-02
4
Medium Priority
?
332 Views
Last Modified: 2012-05-06
I have a field formatted like the following:

last.first (last, first mi)

I need to get just the last.first portion (everything before the first space).  

What's best way to do this?

Thanks,
Matt
0
Comment
Question by:mattturley
  • 2
  • 2
4 Comments
 
LVL 22

Expert Comment

by:Flyster
ID: 24051837
Left(Last.First,Len(Last.First," ")-1)

Flyster
0
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 2000 total points
ID: 24051863


Left(LastFirst,Instr(1, LastFirst," ")-1)

mx
0
 
LVL 75
ID: 24051891
Exmaple

Left("joe, jammer",Instr(1, "Joe, Jammer"," ")-1)

returns

joe,

including the comma.

mx
0
 
LVL 22

Expert Comment

by:Flyster
ID: 24051973
DatabaseMX is correct. I meant to use Instr instead of Len.
Left([Last.First],InStr([Last.First]," ")-1)

If you don't want the comma to show, change the -1 to -2.
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question