Luigi_Cortisone
Registered User.
- Local time
- Today, 23:34
- Joined
- Dec 10, 2008
- Messages
- 24
Hi, hope someone can help
I'm fairly new to vba but I'm sure the answer is in here somewhere.
My table contains the following fields...
ConductorID - a conductor shares one or more (mostly 2) poles with other conductors.
Material - the pole material of each pole related to an individual conductor is stored with the conductor. Because most conductors have multiple poles the table contains duplicate conductor ids.
I have made a query from the table which groups material for each conductor. For most conductors the poles have the same material so there is only one record for the conductor. The pole material is derived as the one specific for that conductor
However where it gets a little more complex is where conductors have a variety of materials - any combination of concrete, wood and unknown.
I need to derive a material for each conductor based on the following logic.
The material with the highest count (eg if wood is '2' and concrete is '1') then the material for that conductor is 'wood'
If the count is the same for a conductor eg concrete is '1' and wood is '1' then the material is 'concrete'' OR if 'unknown' is '1' and wood is '1' the material is wood
If the only material for the conductor is 'unknown' OR 'unknown' is the highest count then the default is 'concrete'
The output will be a list of conductor records with their material derived from the above logic, ie one record only per conductor
I've uploaded a snapdhot of the dB with the source table and query
Many thanks
Cheers, Luigi
I'm fairly new to vba but I'm sure the answer is in here somewhere.
My table contains the following fields...
ConductorID - a conductor shares one or more (mostly 2) poles with other conductors.
Material - the pole material of each pole related to an individual conductor is stored with the conductor. Because most conductors have multiple poles the table contains duplicate conductor ids.
I have made a query from the table which groups material for each conductor. For most conductors the poles have the same material so there is only one record for the conductor. The pole material is derived as the one specific for that conductor
However where it gets a little more complex is where conductors have a variety of materials - any combination of concrete, wood and unknown.
I need to derive a material for each conductor based on the following logic.
The material with the highest count (eg if wood is '2' and concrete is '1') then the material for that conductor is 'wood'
If the count is the same for a conductor eg concrete is '1' and wood is '1' then the material is 'concrete'' OR if 'unknown' is '1' and wood is '1' the material is wood
If the only material for the conductor is 'unknown' OR 'unknown' is the highest count then the default is 'concrete'
The output will be a list of conductor records with their material derived from the above logic, ie one record only per conductor
I've uploaded a snapdhot of the dB with the source table and query
Many thanks
Cheers, Luigi