Results 1 to 4 of 4
  1. #1
    LRSullivan is offline Novice
    Windows XP Access 2003
    Join Date
    Mar 2011
    Posts
    2

    Extracting Data from Beginning of Memo Field and Moving it to Other Fields

    I have a table that stores information about documents. Three of the fields in the table are Author, Recipient and Title fields. Some of the data in this table was imported from an Excel spreadsheet which didn't have Author or Recipient fields. Instead, the spreadsheet creator put the Author and Recipient data in the Title field in the following format: "AuthorName/RecipientName Title" (that's two spaces before the title, and it's the only time as far as I can tell that two spaces are used to separate words in the Title field). To complicate matters, there are a few cases where a / is used in the Title field but does not separate AuthorName and RecipientName. To further complicate matters, there are a few cases where RecipientName is a two word name (none that I saw, though, where AuthorName was a two word name). So here's the obvious question:



    Is there some code I could use to automate the process of stripping the "AuthorName/RecipientName " off the front of the data in the Title field and updating the Author field with AuthorName and the Recipient name to the Recipient field with RecipientName?

  2. #2
    maximus's Avatar
    maximus is offline Expert
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    LRSullivan welcome to the forum. Can u do something can u send me a sample file to work on as the problem is not very clear from your post. If you are not being able to upload the file due to the confidentiality reasons can u atleast give me a some arbitrary data

  3. #3
    LRSullivan is offline Novice
    Windows XP Access 2003
    Join Date
    Mar 2011
    Posts
    2
    I tried sending a message to Maximus with a bit of sample data embedded in the message, but my vBulletin skillz are not all that they should be. Instead, I'll try to attach the sample data file to this message, for Maximus and for anybody else interested in tackling this.

  4. #4
    djoosten is offline Novice
    Windows XP Access 2003
    Join Date
    Mar 2011
    Location
    Wisconsin
    Posts
    7
    Create the following sub-procedure and call it from a button on a form or from the Immediate Window:

    Call ParseString

    Here is the ParseString sub-procedure:


    Public Sub ParseString()

    Dim sInput As String
    Dim rst As Recordset
    Dim iPos As Integer 'To hold position of double space Title separator
    Dim sAuthRecp As String 'Temporary holding spot for unparsed author and recipient

    Set rst = CurrentDb.OpenRecordset("tblSample", dbOpenDynaset)
    With rst
    Do Until .EOF
    .Edit
    sInput = !Title
    iPos = InStr(sInput, " ")
    If iPos <> 0 Then 'There is a double-space meaning an author/recipient exists
    !Title = Mid(sInput, iPos + 2)
    sAuthRecp = Left(sInput, iPos - 1)
    !Author = Left(sAuthRecp, InStr(sAuthRecp, "/") - 1)
    !Recipient = Mid(sAuthRecp, InStr(sAuthRecp, "/") + 1)


    End If
    .Update


    .MoveNext
    Loop
    .Close
    End With
    Set rst = Nothing

    End Sub

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Extracting text from a field
    By bwash70 in forum Access
    Replies: 4
    Last Post: 11-24-2010, 08:10 PM
  2. Memo Field Not Keeping Data
    By maintt in forum Forms
    Replies: 1
    Last Post: 08-12-2010, 05:55 PM
  3. Extracting text from XML data
    By rob4465 in forum Access
    Replies: 1
    Last Post: 03-18-2010, 06:41 PM
  4. Extracting data after a keyword
    By KerryA in forum Queries
    Replies: 1
    Last Post: 02-11-2010, 09:56 PM
  5. Extracting data from a disastrous excel-style Table
    By milehighfreak in forum Import/Export Data
    Replies: 2
    Last Post: 12-16-2009, 07:13 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums