Solved

Extract Data from Access Record

Posted on 2015-01-24
2
143 Views
Last Modified: 2015-01-24
I need to extract data between _xxx_ based on the sample records below  to a separate Access field... for example MP1
Also I need to extract the data between the last underscore and the period to a separate Access field... for example Mike Smith

Sample Records:
 05_History_MP1_Patricia Ashley.csv
06_Math_MP2_Mike Smith.csv
0
Comment
Question by:shieldsco
  • 2
2 Comments
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
Comment Utility
are all the files .csv files?

place this function in a regular module

Function fnParseInfo(vString As Variant, idx As Integer, Optional Delimiter As String = "_") As String

   Dim myArray() As String
   vString = Replace(vString, ".csv", "")
   myArray = Split(vString, Delimiter)

   If idx < 0 Or idx > UBound(myArray) + 1 Then
      fnParseInfo = ""
  Else
      fnParseInfo = myArray(idx - 1)
   End If
End Function

Open in new window


then create a query like this

select [fieldname], fnParseInfo([fieldname], 3) , fnParseInfo([fieldname], 4)
from tableName

.
0
 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
to handle al types of files
change

vString = Replace(vString, ".csv", "")
with

vString= Left(vString, InStr(vString, ".") - 1)
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now