Solved

Extract Data from Access Record

Posted on 2015-01-24
2
152 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 500 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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

789 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