Delete field if total is zero

  • Thread starter Thread starter dean.brunne
  • Start date Start date
D

dean.brunne

Hi,

I want to loop through the fields and only delete if the total of the
field is zero. Here is some air code that I need help with.

For each fld in tdf.Fields

lngTotal = sum(fld.Name)

If lngTotal = 0 Then

'Delete field

Do not how to do the sum in code.

Please advise.
 
Hi,

I want to loop through the fields and only delete if the total of the
field is zero. Here is some air code that I need help with.

For each fld in tdf.Fields

lngTotal = sum(fld.Name)

If lngTotal = 0 Then

'Delete field

Do not how to do the sum in code.

Please advise.

I'm not understanding this at all.

Do you want to change the structure of the table to remove the field from the
table altogether? Are you summing across records? If so, the code above will
*not* work; you're looking at the design of the table structure, not at the
contents of the table!

Please step back a bit; describe your table and what you're trying to
accomplish. I strongly suspect there are much better ways to do this!

John W. Vinson [MVP]
 
I'm not understanding this at all.

Do you want to change the structure of the table to remove the field from the
table altogether? Are you summing across records? If so, the code above will
*not* work; you're looking at the design of the table structure, not at the
contents of the table!

Please step back a bit; describe your table and what you're trying to
accomplish. I strongly suspect there are much better ways to do this!

John W. Vinson [MVP]

Hi John,

I want to delete the whole field from the structure of the table. I
want to sum 104 records in field 1 then to field 2 then to field 3.
If the sum of all the records in the field is zero then I want to
delete from the table structure.

Regards,

Dean
 
I want to delete the whole field from the structure of the table. I
want to sum 104 records in field 1 then to field 2 then to field 3.
If the sum of all the records in the field is zero then I want to
delete from the table structure.

Again:

THIS IS AN INCORRECT APPROACH within Access.

It's *VERY* bad design to be constantly changing the structure of your table.

You are misusing Access.



It's possible to do what you ask, but it's a very bad idea. Do you still want
to do so? If so explain what you mean by "sum 104 records in field 1 then to
field 2". If you really insist, I'll hold my nose and try to write some code
to do this.

Better, explain *what business task you are trying to accomplish* because
there's probably a much better way to do it.


John W. Vinson [MVP]
 
Back
Top