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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Removing first character IF

Status
Not open for further replies.

gtroiano

Technical User
Nov 7, 2001
99
US
i am trying to make an update query that will remove a negative sign(-) from in front of a string if it is present and add a negative sign(-) to the front of the string if there is not one present. thanks.

jerry.
 
Use this for the SQL Statement:

SELECT IIf(Left([FieldName],1)="-",Right([FieldName],Len([FieldName])-1),"-" & [FieldName]) AS Result
FROM tblTableName;

Or in the query builder window use this for one of the columns:

Result: IIf(Left([FieldName],1)="-",Right([FieldName],Len([FieldName])-1),"-" & [FieldName])

Pat B
 
that gets the information i need but i need it to actually update the table. sorry, but my SQL knowledge is bad. any ideas?

jerry.
 
Create a query. Add the field you want to update. Change it to an update query (click on query and then update on the menubar). Paste the following in the "Update To" cell on the grid for the field selected:

IIf(Left([YourFieldName],1)="-",Right([YourFieldName],Len([YourFieldName])-1),"-" & [YourFieldName])

This will permenently update the records for you.
Pat B
 
perfect. worked like a charm.
thanks a lot.

jerry.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top