[AccessD] Iteration construct to print variables

Geldart, Robert RGeldart at detma.org
Tue Mar 11 14:55:00 CST 2003


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; c7; cr; c8; cr;
c9; cr; c10
  Print #1, c11; cr; c12; cr; c13; cr; c14; cr; c15; cr; c16; cr; c17; cr;
c18; cr; c19; cr; c20
  ...

It allows me to condense the code so I can output ten data items per line.

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


> -----Original Message-----
> From: Geldart, Robert [mailto:RGeldart at detma.org]
> Sent: Tuesday, March 11, 2003 1:40 PM
> To: 'accessd at databaseadvisors.com'
> Subject: [AccessD] Iteration construct to print variables
> 
> 
> List,
> 
> 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.
> 
> Thanks for your help,
> 
> Bob Geldart
> RGeldart at detma.org
> Massachusetts Department of Employment & Training
> _______________________________________________
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
> 



More information about the AccessD mailing list