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

strip first character from a string 3

Status
Not open for further replies.

hefly

Technical User
Feb 6, 2008
134
0
0
US
I have a field "address" which has a period as a leading character. I need to remove that leading period. Other periods in the string remain.

tbl_db1.address

I have found String.remove method that allows the removal of a character from my string. How do I point the module to the field in my table?

Thanks.

Hefly
 
Have a look at the Mid function.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I found the function string.remove method, but I dont know how to point the function to the field in my table.

 
It's pretty easy to do this in a query:

TrimAddress: Right([address],(Len([address])-1))

Hope that helps
 
How are ya hefly . . .

Here a query/SQL that will remove all leaing '.'s from the address field in the table ([blue]backup the table 1st![/blue] ... just in case):
Code:
[blue]UPDATE [purple][b]YourTableName[/b][/purple] 
SET [Address] = Right([Address],Len([Address])-1) 
WHERE (Left([Address],1)=".");[/blue]

[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Hmmm:

I am running:

Code:
UPDATE tbl_hyperlinkparts
SET [addr2] = Right([addr2],Len([addr2])-1) 
WHERE (Left([addr2],1)=".");

And get a compile error in expression:

'Right(addr2],Len([addr2])-1)'

 
hefly . . .

I ran this as the SQL of a query. In VBA it would be:
Code:
[blue]   Dim db As DAO.Database, SQL As String
   
   Set db = CurrentDb
   
   SQL = "UPDATE tbl_hyperlinkparts " & _
         "Set [addr2] = Right([addr2], Len([addr2]) - 1) " & _
         "WHERE (Left([addr2],1)='.');"
   db.Execute SQL, dbfainonerror
   
   Set db = Nothing[/blue]
Note: in vba I changed [red]"[/red].[red]"[/red] to [red]'[/red].[red]'[/red] ... (double quotes to single).

[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
hefly . . .

Hit submit too soon. [blush]

Note that the [blue]WHERE claus[/blue] prevents stripping the 1st character [blue]in case its not a period[/blue].

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
AceMan1... You are awesome!!!

THANK YOU.

Hefly
 
hefly . . .

BTW ...
Code:
[blue]   db.Execute SQL, dbfai[red][b]n[/b][/red]onerror
should be
   db.Execute SQL, dbFai[red][b]l[/b][/red]OnError[/blue]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
What about this simpler way ?
Code:
SQL = "UPDATE tbl_hyperlinkparts SET addr2=Mid(addr2,2) WHERE addr2 Like '.*'"

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top