Access 2003:Column Width of FieldsName & FieldsValue to Line up Co

G

Guest

Hi all,
I have the following code statements to print my results in the "Immediate"
box:
////////// - Code Statements-/////////////////
'Loop Through and Display The Field Names
Msg = " "
For i = 0 To rs.Fields.Count - 1
Msg = Msg & "|" & rs.Fields(i).Name
Next
MsgBox Msg

'Loop Through and Display The Field Values for Each Record
Msg = " "
Debug.Print rs.Fields(0).Name; rs.Fields(6).Name; rs.Fields(7).Name;
rs.Fields(8).Name; rs.Fields(9).Name
rs.MoveFirst
Do While (Not rs.EOF)

If rs.Fields(0).Value = "676 NICH(BASEMENT)" Then
Debug.Print rs.Fields(0).Value, rs.Fields(6).Value, rs.Fields(7).Value,
rs.Fields(8).Value, rs.Fields(9).Value
End If

rs.MoveNext
Loop

MsgBox ("Connection was successful.")
////////////The Results in the "Immediate"
Box//////////////////////////////////
ClientSampleIDAnalyteNameResultResultUnitsLabQualifier
676 NICH(BASEMENT) Trichloroethene 1.1 ug/m3
Null
ClientSampleID AnalyteName Result
ResultUnits ClientSampleIDAnalyteNameResultResultUnitsLabQualifier
676 NICH(BASEMENT) Dichlorodifluoromethane 2.6 ug/m3
Null
676 NICH(BASEMENT) Chloromethane 1.6 ug/m3 Null
676 NICH(BASEMENT) Vinyl chloride 0.51 ug/m3
U
676 NICH(BASEMENT) Bromomethane 0.78 ug/m3 U
676 NICH(BASEMENT) Chloroethane 0.53 ug/m3 U
**************************************
1) In the first line of the Results, all the Fields Names are printed
togather. How can I put some variable spacing between two FieldsNames?
2) In the Results (from the second line on), some Value numbers are so close
the chemical names. How can I control the column width for each column in
order to print each column to line uo from the Top to the Bottom of each
column?

Please help and advise.

Thanks in advance,
SHC
 
M

Marshall Barton

SHC said:
I have the following code statements to print my results in the "Immediate"
box:
////////// - Code Statements-/////////////////
'Loop Through and Display The Field Names
Msg = " "
For i = 0 To rs.Fields.Count - 1
Msg = Msg & "|" & rs.Fields(i).Name
Next
MsgBox Msg

'Loop Through and Display The Field Values for Each Record
Msg = " "
Debug.Print rs.Fields(0).Name; rs.Fields(6).Name; rs.Fields(7).Name;
rs.Fields(8).Name; rs.Fields(9).Name
rs.MoveFirst
Do While (Not rs.EOF)

If rs.Fields(0).Value = "676 NICH(BASEMENT)" Then
Debug.Print rs.Fields(0).Value, rs.Fields(6).Value, rs.Fields(7).Value,
rs.Fields(8).Value, rs.Fields(9).Value
End If

rs.MoveNext
Loop

MsgBox ("Connection was successful.")
////////////The Results in the "Immediate"
Box//////////////////////////////////
ClientSampleIDAnalyteNameResultResultUnitsLabQualifier
676 NICH(BASEMENT) Trichloroethene 1.1 ug/m3
Null
ClientSampleID AnalyteName Result
ResultUnits ClientSampleIDAnalyteNameResultResultUnitsLabQualifier
676 NICH(BASEMENT) Dichlorodifluoromethane 2.6 ug/m3
Null
676 NICH(BASEMENT) Chloromethane 1.6 ug/m3 Null
676 NICH(BASEMENT) Vinyl chloride 0.51 ug/m3
U
676 NICH(BASEMENT) Bromomethane 0.78 ug/m3 U
676 NICH(BASEMENT) Chloroethane 0.53 ug/m3 U
**************************************
1) In the first line of the Results, all the Fields Names are printed
togather. How can I put some variable spacing between two FieldsNames?
2) In the Results (from the second line on), some Value numbers are so close
the chemical names. How can I control the column width for each column in
order to print each column to line uo from the Top to the Bottom of each
column?


Well you can add some spacing using something like:

Debug.Print rs.Fields(0).Name; Spc(3); rs.Fields(6).Name;
Spc(3); rs.Fields(7).Name; Spc(3); rs.Fields(8).Name;
Spc(3); rs.Fields(9).Name

BUT no matter what you try, you are not going to get a
perfect result without going to a LOT more effort. It's
just not worth the effort to try to make it look nice in
the immediate window, which should only be used for
debugging purposes.

To get nice looking output, use a report.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top