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

Removing Characters From String

Status
Not open for further replies.

supervi

MIS
Mar 22, 2003
61
CA
Hello,

I have a simple question yet I can't get it to work. I have a String with about 50 characters. How would I go about removing the 1st 13 digits ?

Thanks in advance for any input.
 
In a form, I'd set up the control source of a text box with:

[tt]=Mid(FieldName,14)[/tt]

which would display what you ask for. Or are you talking about actually removing the characters from the field? If so create an update query using the same expression on the field.

Roy-Vidar
 
Str1 = "1234567890123"

Str2 = mid(str1,1,13) gets the left 13 characters
str3 = right(str1) gets the right 13 characters.


rollie@bwsys.net
 
Yes i am actually talking about removing the first 13 characters from the field...
i.e

str = "12345678901231234567890123"

str.sliceanddice.left.thirteencharacter

--

After that if i call str and it now equals

"1234567890123"

Is their a piece of code that can do that??

Thanks in advance
 
Do not use str as a variable as it is a reserved word and should not be used. If I change to str1 then:

str1 = "12345678901231234567890123"

str1 = mid(str1,1,13) will do the trick!!

R
 
Not working the way i want it to work let me try using an example


---
Dim count as Double
Dim recordnumber as Double
Dim str1 As String



Count = 2
recordnumber = 0
str1 = "abcdefghijklmonpqrstuvwxyz"

While recordnumber <> Count

Msgbox Left(str1,13)
str.sliceanddice.left.thirteencharacter
recordnumber= recordnumber+1
Wend
----

this is what i want to popup

(MSGBOX1) abcdefghijklm
(MSGBOX2) nopqrstuvwxyz


Thats what i want to happen with the cutting of the first thirteen letter code

I hope that makes sense



 
[tt]dim lCounter as long
dim lDiff as long
lDiff = 13
dim str1 as string
str1 = "abcdefghijklmonpqrstuvwxyz"
for lCounter = 1 to 2
msgbox mid$(str1,((lCounter-1)*lDiff)+1,lDiff)
next lCounter[/tt]

Or:
[tt]msgbox mid$(str1,1,13)
msgbox mid$(str1,14)[/tt]

But this only displays things, not remove. In my first reply, I mention the concept of using a query to REMOVE it from the field. And there is some mention of the text manipulation functions, mid, left, right etc in the help files.

Roy-Vidar
 
I GOT IT WORKING!!!!
thanks to all
i'll paste my code incase your wondering what i did..

and i know ..i gotta clean it up



Dim A1 As String
Dim B1 As String
Dim C1 As String
Dim D1 As String
Dim E1 As Date
Dim num As Double

Dim X As String
Dim x2 As String

If Len(Me.Deal_Ticket_Number & "") = 0 Then

If Len(Me.Version & "") = 0 Then

X = MsgBox("You have not successfully completed the form. Please review", 48, "Amendment Failed")

End If
End If

If Len(Me.Deal_Ticket_Number & "") <> 0 Then

If Len(Me.Version & "") <> 0 Then


Dim reccount As Integer
Dim temp As Integer

temp = 0

reccount = Forms![PPFT Form]![Site IDs subform]![recnumber]

Me.Site_IDs_subform.SetFocus

DoCmd.DoMenuItem A_FORMBAR, A_RECORDSMENU, 1, 0, acMenuVer20

While reccount <> temp

If Len(Forms![PPFT Form]![Site IDs subform]![Site ID] & "") <> 0 Then

A1 = A1 + Forms![PPFT Form]![Site IDs subform]![Site ID]

End If


If Len(Forms![PPFT Form]![Site IDs subform]![Date Added] & "") <> 0 Then
D1 = D1 + Forms![PPFT Form]![Site IDs subform]![Date Added]

End If
Me.Site_IDs_subform.SetFocus
DoCmd.DoMenuItem A_FORMBAR, A_RECORDSMENU, 1, 2, acMenuVer20
temp = temp + 1

Wend




Me.Account_Setup.SetFocus




On Error GoTo Err_Command221_Click


DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70 'Paste Append

DoCmd.GoToRecord , , acLast

Forms![PPFT Form]![Site IDs subform]![Deal Ticket Number] = Me.Deal_Ticket_Number
Forms![PPFT Form]![Site IDs subform]![Version] = Me.Version


Dim temp2 As Double
Dim lDiff As Long
lDiff = 13
Dim temp5 As Long
Dim diff2 As Long
diff2 = 10
Dim temp6


Me.Site_IDs_subform.SetFocus

DoCmd.DoMenuItem A_FORMBAR, A_RECORDSMENU, 1, 0, acMenuVer20

While num <> reccount

If Len(A1 & "") > 0 Then



Forms![PPFT Form]![Site IDs subform]![Site ID] = Mid$(A1, (temp5 * lDiff) + 1, lDiff)

temp5 = temp5 + 1
End If


If Len(D1 & "") > 0 Then

Forms![PPFT Form]![Site IDs subform]![Date Added] = Mid$(D1, (temp6 * diff2) + 1, diff2)
temp6 = temp6 + 1
End If

num = num + 1
Me.Site_IDs_subform.SetFocus
DoCmd.DoMenuItem A_FORMBAR, A_RECORDSMENU, 1, 2, acMenuVer20

Wend






Exit_Command221_Click:
Exit Sub

Err_Command221_Click:
MsgBox Err.Description
Resume Exit_Command221_Click

End If
End If
End Sub
 
Props go out to Rolliee who helped this newbie out big time
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top