Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Function to select on part of a field?

Status
Not open for further replies.

CraigBest

Programmer
Joined
Aug 1, 2001
Messages
545
Location
US
Sorry for a very simple question...

I have a Account number field in a table, in which the first tow letters are a portfolio code. I want to make a field in my query that collects only the first two characters from that field so I can sort on that. I don't know the name of the function but I know it uses the statement "1 to 2" as a parameter to select which characters you want to select. Can someone tell me the name of this function please?

Thanks

Craig
 
Try this..

add a column in the field name on the query
Code:Left([fieldname],2)
This will return the first two characters of the field.

Sean
 
Lakers8175;

I get an error message when I try this...

"Incorrect Syntax Near 'code:'"

I'm writing the query as a string variable in a VB program, which gets passed to an ADODB Connection while opening a recordset object. I tried your suggestion both in the Select section and the Where section, same results in either place.

 
I found what I was looking for, the SUBSTRING function. Syntax in SQL 7 is different from my boo, that's why I had a hard time locating it. Thanks anyway!

Craig
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top