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

How to format text retreived from a recordset

Status
Not open for further replies.

ToeJamNEarl

Programmer
Jan 26, 2004
91
US
Hello guys,

I have a question for you all.

I have a recordset that contains two fields fields:
'Parent_Value' and 'Child_Value'.

a sample of the data contained inside would be as follows.

...

sport tennis
sport hockey
sport basketball
sport baseball
hobby carpentry
hobby painting
hobby model building

...

I want to be able to output the data inside those tables to a text file, but would like to suppress the duplicated parent_value fields, so as to represent a grouping.

How would I be able to achieve an output like the following:

sport tennis
hockey
basketball
baseball
hobby carpentry
painting
model building


Thank you,

-Diran
 
If you populpate your recordset using a select statement of the form

SELECT Parent_Value, Child_Value FROM MyTable ORDER BY Parent_Value

then, you can have code something like

Code:
dim PvParent as string, MyRs as ADODB.Recordset
.
.
with MyRs
  .MoveFirst
  do while not .eof and not .bof
    if !Parent_Value <> PvParent then
      Print #1, !Parent_Value & vbtab & !Child_Value
      pvParent = !Parent_Value
    else
      Print #1, vbtab & !Child_Value
    end if
    .movenext
  loop
  .close
end with
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top