Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / May 2008

Tip: Looking for answers? Try searching our database.

Extract text out of textbox

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
billybanter67 - 17 May 2008 06:16 GMT
I have a text box which has peoples address details in it, included in
this one text box is the persons name, address incl post code and
suburb. The reason this is in one text box is that I sell some items
on ebay and I just copy the buyer details and use this code listed
below to paste it into a text box field, from there I copy and paste
it in to each individual field.

Private Sub BillingAddress_DblClick(Cancel As Integer)

On Error GoTo Err_BillingAddress_DblClick
Me.BillingAddress.SetFocus
RunCommand acCmdPaste
EmptyClipboard
Exit_BillingAddress_DblClick:
   Exit Sub

Err_BillingAddress_DblClick:
   'MsgBox Err.Description
   Resume Exit_BillingAddress_DblClick
End Sub

What I want to do is to extract say the person first name and then the
post code.

RICHARD HEWSON
12 SMITH STREET
BURWOOD EAST  VIC 3151

So what I want here is to extract the "RICHARD" to a textbox called
firstname and the "3151" to a textbox postcode.

Any ideas?

thanks
Linq Adams - 17 May 2008 12:58 GMT
Assuming that the format is ALWAYS as you've shown it here

Me.txtFirstName = Left(Me.txtAddressDetails, InStr(txtAddressDetails, " "))

Me.txtPostCode = Right(Me.txtAddressDetails, Len(txtAddressDetails) -
(InStrRev(txtAddressDetails, " ")))

Signature

There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

billybanter67 - 17 May 2008 23:33 GMT
works perfect, thanks for your effort.

Now if I wanted to extract the "BURWOOD EAST " what would I do?
Thanks
ruralguy - 18 May 2008 03:24 GMT
Here's a function for you.
Function Foo(InString As String) As String

Dim a As Long
Dim b As Long
Dim c As Long
Dim d As Long

c = Len(InString)
a = InStrRev(InString, " ")
b = InStrRev(InString, " ", a - 1)
d = InStrRev(InString, Chr(10))

Foo = Mid(InString, d + 1, b - d)

End Function

>works perfect, thanks for your effort.
>
>Now if I wanted to extract the "BURWOOD EAST " what would I do?
>Thanks

Signature

RuralGuy (RG for short) aka Allan Bunch MS Access MVP - acXP WinXP Pro
Please post back to this forum so all may benefit.

billybanter67 - 18 May 2008 09:07 GMT
Hi again,

Thanks, now I have placed this function in a module.

Could you pls explain the use of this.

Regards
Richard

> Here's a function for you.
> Function Foo(InString As String) As String
[quoted text clipped - 12 lines]
>
> End Function
ruralguy - 18 May 2008 17:16 GMT
Use it like:
Me.txtPostCity = Foo(Me.txtAddressDetails)
and it should pull 'BURWOOD EAST' from your example.

>Hi again,
>
[quoted text clipped - 10 lines]
>>
>> End Function

Signature

RuralGuy (RG for short) aka Allan Bunch MS Access MVP - acXP WinXP Pro
Please post back to this forum so all may benefit.

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.