Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 535
  • Last Modified:

Extract part of information from a text field on Access 2003 form

I have a field on a form (text1)that displays the complete smtp email address for a cell phone.I am using  a command button on click event to try to extract the actual phone number up to the “at” sign and place it in text2 . Is this doable?

Text1= 3345552654@vtext.com
Text2=3345552654
0
mickeyshelley1
Asked:
mickeyshelley1
  • 6
  • 4
  • 3
  • +2
1 Solution
 
jerryb30Commented:
me.text2 = left(me.text1, instr(me.text1, "@")-1)
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
Val("3345552654@vtext.com")

 returns 3345552654

mx
0
 
Kelvin SparksCommented:
Use a function such as
Left(me.Text1,Instr(1,Me.text1,"@")-1) in a query or VBA to return the number

Kelvin
0
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
Dale FyeCommented:
you could set the control source of text2 to:

=Left([Text1], instr([Text1] & "@", "@")-1)

If there is no @ symbol in the [Text1] it will return the entire string
0
 
Dale FyeCommented:
Joe,

I keep forgetting about that option.
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
Val() ... too simple !
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
Private Sub btnSomeButtonName_Click()
    Dim x
    x =  Val(Me.YourTextBoxName)
 End Sub
0
 
mickeyshelley1Author Commented:
Thanks this works great...
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
:-)

Let's see.  Two functions vs one ... hummm.

valCapture1.gif
0
 
mickeyshelley1Author Commented:
“Every man is my superior in that I may learn from him.”


¿ Thomas Carlyle
0
 
mickeyshelley1Author Commented:
I apologize for not evaluating post by DatabaseMX on 2013-01-28 at 18:37:02ID: 38827929 after trying this approach it did work equally as well with less clutter. It's simplicity caused me me to overlook it fearing I didn't completely understand it. I will not make this mistake again.
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
:-(

" It's simplicity caused me me to overlook it fearing I didn't completely understand it"
Really ?  In general, Less is always More ...
0
 
mickeyshelley1Author Commented:
lol i understand, i requested that the moderator review my awarding of points, you have provided me with sound advice over the years, i acted in haste...
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
no worries ...
0
 
jerryb30Commented:
Here lies Lester Moore
Shot dead by a .44
No les
No more
0
 
Dale FyeCommented:
Redistribute away!  I was wondering why you selected mine, after MX posted his elegant solution.  For some reason, I always forget about that option.
0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

  • 6
  • 4
  • 3
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now