 |
| Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

July 8th, 2003, 10:59 AM
|
|
Authorized User
|
|
Join Date: Jun 2003
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Space in Expression
How can you put a space in an expression. I have a table that I want to combine the FNAME and LNAME Fields, and I can do it, but it puts it together as one word. I just wrote an expression that is:
FLNAME: COLLECTOR!FNAME+COLLECTOR!LNAME
Thanks in advance for any help,
Kevin
|
|

July 8th, 2003, 11:24 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
|
|
Quote:
quote:Originally posted by kev_79
How can you put a space in an expression. I have a table that I want to combine the FNAME and LNAME Fields, and I can do it, but it puts it together as one word. I just wrote an expression that is:
FLNAME: COLLECTOR!FNAME+COLLECTOR!LNAME
|
Kevin, note concatenation of strings is done via the ampersand (&). To include the space, just attach it in the middle, i.e.
FLNAME: COLLECTOR!FNAME & " " & COLLECTOR!LNAME
Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
|
|

July 8th, 2003, 12:16 PM
|
|
Authorized User
|
|
Join Date: Jun 2003
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
It worked!!! Thanks so much!:D:D
|
|

July 9th, 2003, 08:01 AM
|
|
Authorized User
|
|
Join Date: Jun 2003
Posts: 91
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Greg has your answer for you
Kenny Alligood
|
|

August 14th, 2003, 12:48 PM
|
|
Authorized User
|
|
Join Date: Aug 2003
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
OK...How about going the opposite direction. I have a name field and I want to break it into to fields FName and LName. I was trying to find a way using access help for substrings, but couldn't find anything. Any suggestions?
-Tim
|
|

August 14th, 2003, 12:57 PM
|
|
Friend of Wrox
|
|
Join Date: Jul 2003
Posts: 174
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
What is the format of your Name field? Is the data entry of varied types or is it consistent?
Doe, John
Doe, John R
Doe Jr, John R
John Doe
John R Doe
Some basic info would assist us in helping you.
Beth M
|
|

August 14th, 2003, 01:53 PM
|
|
Authorized User
|
|
Join Date: Aug 2003
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
It is consistent: John Doe
|
|

August 14th, 2003, 02:24 PM
|
|
Friend of Wrox
|
|
Join Date: Jul 2003
Posts: 174
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
If you are using Access 2000 or 2002 you can use the InStrRev function like the following to retrieve the left half of the string:
Left([FieldName],InStrRev([FieldName]," ")-1)
Below is used for the right:
Right([FieldName],Len([FieldName])-InStr(1,[FieldName]," "))
HTH,
Beth M
|
|

August 14th, 2003, 03:14 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
|
|
Hi Tim,
Another approach to take if you want to merge the parsed names into a table of there very own which has a strcuture identical to the table with the unparsed full-name field is to:
1. Copy your original table's structure only.
2. Add columns to the new table for the parsed firstname and the
parsed lastname fields.
Your original table might be: tblFullName
PersonID
FullName
Your new empty table might be: tblParsedNames
PersonID
FirstName
LastName
Run the following append query. Make sure your table names and field names match the names in the query and that you are using the same data types in the two tables:
INSERT INTO tblParsedNames ( PersonID, FirstName, LastName )
SELECT
tblFullName.PersonID,
Mid([FullName],1,InStr([FullName],Chr(32))-1) AS FirstName,
Mid([FullName],InStr([FullName],Chr(32))+1) AS LastName
FROM tblFullname;
As long as your new table's field list and the fields in the INSERT statement are the same, you can add as many fields to the new table from your original table as you like. Just another way to go.
HTH
Bob
|
|

August 20th, 2003, 09:38 AM
|
|
Authorized User
|
|
Join Date: Aug 2003
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
COOL!!! Thanks alot to both of your ideas Beth and Bob. I tried them out and they work great!
Thanks
-Tim
|
|
 |