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

Microsoft Access Export to special format

Status
Not open for further replies.

mikeconn

IS-IT--Management
Nov 6, 2002
13
0
0
US
I have a MS Access database with four fields (just consider they are Title, Author, Info1, Info2 for the sake of discussion). Info2 contains lots of text that is in RTF format. I have two issues. I need to strip out the RTF coding and get just the text from it, and then the second issue is that I need to take each record and put the field names in front of the appropriate data for each field. So if I have a record that is

My Book,Mike,Info on My Book,Info2 on My Book

then I need the output to look like this:
Title: My Book
Author: Mike
Info1: Info on My Book
Info2: Info2 on My Book

If anyone can point me to some code for these options, let me know.

Thanks,
Mike
 
Hi
Sorry, not got enough time to do the code, but I'd try doing something like this:-

Create a string to hold it all
Open recordset
Do Until rst.EOF
Concatenate the records & headings,& crlf's into the string for each record
Loop

Create a text file from the string contents.

HTH - I'll work out the code later if I get a chance!

 
I think your RTF field is an OLE object field, correct?
Code:
Sub YourTxt(ByVal FullPathAndFileNameWithExtension As String)

Dim myFreeFileNo As Long
Dim Cur_Db As DAO.Database
Dim rst As DAO.Recordset
Dim myChunk As String

Set Cur_Db = CurrentDb
Set rst = Cur_Db.Execute("Select * From myTable")
myFreeFileNo = FreeFile
Open FullPathAndFileNameWithExtension For Output Access Write As #myFreeFileNo
With rst
    While Not .EOF
        Write #myfreefile, "Title: " & .Fields("Title").Value & ""
        Write #myfreefile, "Author: " & .Fields("Author").Value & ""
        Write #myfreefile, "Info1: " & .Fields("Info1").Value & ""
        Set myChunk = .Fields("Info2").GetChunk(0, .Fields("Info2").FieldSize) & ""
        Write #myfreefile, "Info2: " & myChunk
        .MoveNext
    Wend
    .Close
End With
Set rst = Nothing
Close #myfreefile

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top