extracting certain length of text field

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How can I extract just the first few characters of a text field?

What I'm trying to do is merge the first 4 letters of one field (a last
name) and the first two from another (a first name).

For example if I have the name of Williams in one field and name Tom in the
next, I want to end up with willito in the final field. I also want this
final field to be all lower case.

I'd prefer to use some type of update query as I have hunderds of such name
mergings to do.

I'm using Access 2000

Thanks in advance for your help,
 
LCase and Left functions will do what you want:

UPDATE TableName
SET Field3 = LCase(Left(Field1, 4) & Left(Field2, 2));
 
Simple update query.

UPDATE YourTable
SET YourNewField = LCase(Left([LastName],4) & Left([FirstName],2))

This of course runs into a problem with records with no last name or no first
name. So to prevent errors try

UPDATE YourTable
SET YourNewField = LCase(Left([LastName] & "",4) & Left([FirstName] & "",2))
 
Back
Top