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

VBA Question

Status
Not open for further replies.

abe6162

Programmer
Sep 7, 2004
24
US
I am new to VBA and I doing this is my first Access project.
I get a response from a user all the time as "USA ...". I really need to put "USA" into the database. How can I do this in VBA? I am used to the c programming language where I can loop through the string array looking for ".". Is there a way to get the string into an array? I can loop for ".", unless there is an easier way.
 
Access has the Instr function that will give the location of the "." and the Mid Function can extract the data.

Dim location as Integer, thedata as String

example.
location = instr(yourvariable,".")
thedata = mid(yourvariable,thestart,theend)

thedata = Mid(yourvariable,1,instr(yourvariable,".")

 
You may also try this (ac2k or above):
newData = Trim(Split(oldData, ".")(0))

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks for you idea. I really appreciate them. Both are great solutions.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top