In a programming language like Clipper you can code
for i = 1 to 12
ai=str(i)
replace Sales&ai with 0
next i
where the fields in a table are called Sales1, Sales2, Sales3, etc
How can this be done in Access?
In a programming language like Clipper you can code
for i = 1 to 12
ai=str(i)
replace Sales&ai with 0
next i
where the fields in a table are called Sales1, Sales2, Sales3, etc
How can this be done in Access?
for controls in a form or report called Sales1, Sales2 etc you would use
with a table in VBA, you need a recordset and your code would be something likeCode:for i = 1 to 12 me("Sales" & i)= 0 next I
Code:dim rst as dao.recordset set rst=currentdb.openrecordset ("SELECT * FROM myTable") if not rst.eof then with rst for I=1 to 12 .fields("Sales" & I)=0 next I end if
.
I agree with Ajax's answer to your specific question.
However, if you have a table with Sales1, Sales2...SalesX, you may want to review your table or processing. This typically signals an un-normalized table structure. Relational databases use Normalized tables.
See this on Normalization -repeated columns.
Thanks Ajax.
The VBA/Recordset solution works fine (after a bit of trial and error!!!)