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

x
?
Solved

Extract Data from Access Record

Posted on 2015-01-24
2
Medium Priority
?
165 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 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 2000 total points
ID: 40568184
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 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 40568193
to handle al types of files
change

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

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

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

916 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