[AccessD] Iteration construct to print variables

Geldart, Robert RGeldart at detma.org
Thu Mar 13 07:20:00 CST 2003


Stuart, and Marty,

A little further explanation (there's always more....)

1. There are actually 97 data fields to be output. I used 20 as it seemed an
easier number to deal with, theoretically.

2. The module produces a data file for uploading state agency data to a
Federal database. Feds refer to the data fields as "cells", thus identifying
the data items "c1", "c2", ... "c97".

3. The data comes from a Query which is also used for an internal report.
Thus, I have more meaningful fieldnames ("num_Lapse_Under8") which I recode
as "c10" in the module, for ease of debugging and understanding what the
Feds are expecting.

4. I do computation of sums on my report. However, Feds take totals as data
cells, so I need to compute them in the module. Not a problem, but Feds have
c1...c8 as column totals, and c9, c17, c25, c33, etc, as row totals.

All of this would seem to make arrays, or any logical sequential action by
cell name or cell number a real problem. So I've settled on incorporating a
number of Print statements. It ain't pretty, but it works alright.

I do thank you for your time and suggestions.

Bob Geldart
RGeldart at detma.org
Massachusetts Department of Employment & Training


> -----Original Message-----
> From: MartyConnelly [mailto:martyconnelly at shaw.ca]
> Sent: Tuesday, March 11, 2003 8:34 PM
> 
> 
>  How about
> 
>  dim c(20) as long ' or use variant
>  dim i as long
> 
>  then something like
>   c(1) =  rst !fieldone
>   c(4) =c(1) +c(2)
> 
>   debug.print concstring(c())
> 
> where
> 
> Function concstring(arrc()) As String
> 'concatenate array to string
> Dim strTemp As String
> Dim k As Long
>  strTemp = ""
>   For k = 1 To UBound(arrc)
>    strTemp = strTemp & arrc(k) & vbCrLf
>   Next k
>   concstring = strTemp
>  
> End Function
> 
> Geldart, Robert wrote:
> 
> >I found a way to do it that works almost as well...
> >
> >Dim cr as string
> >cr = vbCrLf
> >
> >  Print #1, c1; cr; c2; cr; c3; cr; c4; cr; c5; cr; c6; cr; 
> >  Print #1, c11; cr; c12; cr; c13; cr; c14; cr; c15; cr; 
> >  ...
> >
> >It allows me to condense the code so I can output ten data 
> >items per line.
> >
> >Bob Geldart
> >
> >>-----Original Message-----
> >>From: Geldart, Robert [mailto:RGeldart at detma.org]
> >>Sent: Tuesday, March 11, 2003 1:40 PM
> >>
> >>I'm doing an output to file routine in a module. 
> >>
> >>I have a number of variables dimmed as long -- c1, c2, c3, 
> >>c4, ... c20 
> >>
> >>The data file is required to put each data field on a separate line:
> >>	tDate
> >>	c1
> >>	c2
> >>	...
> >>	c20
> >>
> >>My data is a single recordset of a query. I make a number of 
> >>calculations and then output all the  results:
> >>
> >>	c1 = rst!FieldOne
> >>	c2 = rst!FieldTwo
> >>	c3 = rst!FieldThree
> >>	c4 = c1 + c2 + c3
> >>	...
> >>	Print #1, c1
> >>	Print #1, c2
> >>	Print #1, c3
> >>	Print #1, c4
> >>	...
> >>
> >>It seems to be inefficient to have 20 lines of "Print #1, 
> >>c..." Is there a way I could run a loop something like?
> >>
> >>	For i = 1 to 20
> >>		Print #1, "c" + i
> >>	Next i
> >>
> >>I know that specifically won't work as I tried it, but I hope 
> >>you can see what I'm driving at. I would like to loop through variables 
> >>(c1...c20) and do a Print# for each.
> >>
> >>
> >>Bob Geldart



More information about the AccessD mailing list