Hello,
I have one field that has a comma between the first and last name. The
rest of the fields are fine. Is tehre any way to separate the first
and last name?
If it is easier in Excel..Please let me know.
|
|
0
|
|
|
|
Reply
|
Beagle1927
|
9/19/2007 2:05:36 PM |
|
Since this is in the Queries room, I would guess that is what you are trying
to do.
If you are using the Query builder, you can create two calculated fields. I
am assuming there will be a space following the comma as in "Longbow, Frodo"
Fname: Left([Name],Instr([Name],",")-1)
Lname: Mid([Name],Instr([Name],"<")+2)
--
Dave Hargis, Microsoft Access MVP
"Beagle1927" wrote:
> Hello,
>
> I have one field that has a comma between the first and last name. The
> rest of the fields are fine. Is tehre any way to separate the first
> and last name?
>
> If it is easier in Excel..Please let me know.
>
>
|
|
0
|
|
|
|
Reply
|
Utf
|
9/19/2007 5:24:05 PM
|
|
On Sep 19, 1:24 pm, Klatuu <Kla...@discussions.microsoft.com> wrote:
> Since this is in the Queries room, I would guess that is what you are trying
> to do.
> If you are using the Query builder, you can create two calculated fields. I
> am assuming there will be a space following the comma as in "Longbow, Frodo"
>
> Fname: Left([Name],Instr([Name],",")-1)
> Lname: Mid([Name],Instr([Name],"<")+2)
> --
> Dave Hargis, Microsoft Access MVP
>
>
>
> "Beagle1927" wrote:
> > Hello,
>
> > I have one field that has a comma between the first and last name. The
> > rest of the fields are fine. Is tehre any way to separate the first
> > and last name?
>
> > If it is easier in Excel..Please let me know.- Hide quoted text -
>
> - Show quoted text -
Thanks all..worked like a charm. If it isn't too much trouble could
you walk me through what the expressions are doing?
|
|
0
|
|
|
|
Reply
|
Beagle1927
|
9/19/2007 6:50:27 PM
|
|
A function does not 'starts' before all its arguments are fully evaluated.
So, in
Left([Name],Instr([Name],",")-1)
Left() has to evaluate each of its argument.
[Name] is the string (coming from the field value) to be parsed, ok, it
will be "Longbow, Frodo".
InStr( ) -1 constains a function to be evaluated, InStr. So, let us do
it
InStr( [Name], "," )
The help file tell us that InStr(a, b) returns the position of the
first occurrence of string hold in its second argument, b, within its first
string argument, a. If no occurence is found, it returns 0.
InStr("Longbow, Frodo", ",")
should then return the first occurrence of a coma in: "Longbow, Frodo"
Which is 8, because in position 8, there is the first coma.
So, InStr() returns 8, and InStr()-1 returns thus 7.
Left("Longbow, Frodo", 7)
from the help file, it tell us that the first 7 characters of the string
would be returned, that is, "Longbow" (without hte coma).
The second expression:
Mid( [Name], Instr( [Name], "," )+2 )
is similar. InStr returns, again, 8, so the second argument of Mid() is 10.
Mid("Longbow, Frodo", 10)
would return: "Frodo"
As for the LName: and FName: those indicate name for the columns made of
computed expression.
Hoping it may help,
Vanderghast, Access MVP
"Beagle1927" <ebonystealth@hotmail.com> wrote in message
news:1190227827.316218.220350@50g2000hsm.googlegroups.com...
> On Sep 19, 1:24 pm, Klatuu <Kla...@discussions.microsoft.com> wrote:
>> Since this is in the Queries room, I would guess that is what you are
>> trying
>> to do.
>> If you are using the Query builder, you can create two calculated fields.
>> I
>> am assuming there will be a space following the comma as in "Longbow,
>> Frodo"
>>
>> Fname: Left([Name],Instr([Name],",")-1)
>> Lname: Mid([Name],Instr([Name],"<")+2)
>> --
>> Dave Hargis, Microsoft Access MVP
>>
>>
>>
>> "Beagle1927" wrote:
>> > Hello,
>>
>> > I have one field that has a comma between the first and last name. The
>> > rest of the fields are fine. Is tehre any way to separate the first
>> > and last name?
>>
>> > If it is easier in Excel..Please let me know.- Hide quoted text -
>>
>> - Show quoted text -
>
> Thanks all..worked like a charm. If it isn't too much trouble could
> you walk me through what the expressions are doing?
>
|
|
0
|
|
|
|
Reply
|
Michel
|
9/19/2007 7:16:44 PM
|
|
Actually, there is an error here. It will work, but end up with the wrong
names, so change the names:
Lname: Left([Name],Instr([Name],",")-1)
Fname: Mid([Name],Instr([Name],"<")+2)
The first expression is creating a field in the query named Lname. It will
contain the last name of the person. it looks at the Name field in the table
that contains the LastName, a comma, a space, and the First Name. The Left
function returns the left portion of the text string for the length
specified. For this we use the Instr function which returns the position of
one string within the other. We look in the NAME field for the comma and
subtract 1 which will tell us how many characters to return starting from the
left. The first name works the same way except we use the Mid function so we
know where to start the return of characters.
--
Dave Hargis, Microsoft Access MVP
"Beagle1927" wrote:
> On Sep 19, 1:24 pm, Klatuu <Kla...@discussions.microsoft.com> wrote:
> > Since this is in the Queries room, I would guess that is what you are trying
> > to do.
> > If you are using the Query builder, you can create two calculated fields. I
> > am assuming there will be a space following the comma as in "Longbow, Frodo"
> >
> > Fname: Left([Name],Instr([Name],",")-1)
> > Lname: Mid([Name],Instr([Name],"<")+2)
> > --
> > Dave Hargis, Microsoft Access MVP
> >
> >
> >
> > "Beagle1927" wrote:
> > > Hello,
> >
> > > I have one field that has a comma between the first and last name. The
> > > rest of the fields are fine. Is tehre any way to separate the first
> > > and last name?
> >
> > > If it is easier in Excel..Please let me know.- Hide quoted text -
> >
> > - Show quoted text -
>
> Thanks all..worked like a charm. If it isn't too much trouble could
> you walk me through what the expressions are doing?
>
>
|
|
0
|
|
|
|
Reply
|
Utf
|
9/19/2007 7:26:04 PM
|
|
|
4 Replies
924 Views
(page loaded in 0.083 seconds)
Similiar Articles: Separate By Comma - microsoft.public.access.queriesHello, I have one field that has a comma between the first and last name. The rest of the fields are fine. Is tehre any way to separate the first an... Multiple numbers in a cell separated by a comma, need separate cel ...Multiple numbers in a cell separated by a comma, need separate cells. Is ther a way to take the contents of cell A1 (contains: 192410, 192413, 907... Multi-word string from one field to two fields - microsoft.public ...I have a column with city and state in one field (separated by a space and/or a comma). I want to separate the information into two fields (similar ... Separating strings in a field to separate fields - microsoft ...Hi, I have a field that consists of a string value that looks like Item1, Item2, Item3, each item is separated by commas. I want to separate that st... separate contents of one cell into multiple cells - microsoft ...> > I have this: > > Portugal,KM25,2,euros,2002 > > what I m looking for is separate all this between comma like Portugal > in one cell km25 in other cell 2 in other ... How to remove duplicate text with comma seperated - microsoft ...How to Delete Commas From Excel 2007 | eHow.com How to Delete Duplicates in Excel. Any time a large list is put into Microsoft Excel ... Comma separated text is actually ... Sorting comma strings - microsoft.public.word.docmanagement ...We frequently work with strings of numbers separated by commas (e.g., 6, 55, 8, 341, 21, 4). We sort those numbers by selecting them, replacing comm... Commas and other separator characters in Custom Text Fields ...I pasted SOW paragraph numbers separated by commas into a text field. No problem. Here is the text I want to paste: 3.2.7, 3.2.7.1, 3.2.7.1.1, 3.2.7.1.2, 3.2.7 ... Need to separate and rearrange names - microsoft.public.excel ...Need to separate and rearrange names - microsoft.public.excel ... Separate By Comma ... Multiple numbers in a cell separated by a comma, need separate cel ... Add comma after last " in a cell - microsoft.public.excel ...3/4" x 1/2" pvc pipe 1/2" x 1/2" x 6' black pipe 1' insulated filter This way when i do the text to columns, i can separate the by commas. Comma-separated values - Wikipedia, the free encyclopediaA comma-separated values (CSV) file stores tabular data (numbers and text) in plain-text form. Plain text means that the file is a sequence of characters, with no ... Comma - Wikipedia, the free encyclopediaSome style guides prescribe that two independent clauses joined by a coordinating conjunction (for, and, nor, but, or, yet, so) must be separated by a comma placed before ... How to Use Commas to Separate Data in Excel | eHow.comMicrosoft Excel gives you a variety of options to enter data into cells. Choose from currencies such as the pound or dollar, dates and times, or even custom data that ... Excel 2007/2008: Separating Text, UWEC - University of Wisconsin ...One solution could involve separating cities and states with commas and using the comma as your delimiter. Determine if you should separate your data into three columns ... How to Convert Excel Data to Comma Separated Text | eHow.comComma separated text is actually called CSV or "Comma Separated Value." This file format is often used to exchange data between applications and computers. CSV is ... 7/22/2012 11:56:06 PM
|