spacepro
Registered User.
- Local time
- Today, 05:50
- Joined
- Jan 13, 2003
- Messages
- 715
Assign Value to table based on recordset
Hi All,
I was wondering if anyone can help me in trying to write some vb code for the following purpose:
I want to loop through records until a quantity of 21 is reached then assign a value to a field then carry on with the loop.
If 21 can't be met 20 or 19 is OK but much be round up to the nearest number.
Example:
Record 1 - No of Lanes = 9.22222
Record 2 - No of Lanes = 14.11112
Record 3 - No of Lanes = 12.333328
Record 4 - No of Lanes = 8.7888954
So Value 0f the field I want to assign will be as follows:
1
2
3
4
So the formula should be something like
If record 1 = 21 then
assign value of 1 . If not then go to next record and add quantities together. If = 21 then assign value = 1 but must = 21 exactly . If quantities over 21 then create duplicate record and adjust quantity to balance (balance minus 21) on the duplicate record.
Then procede to the duplicate and then loop through the records has above until all data in table has been assigned a value in the required field.
I understand this could take time, just don't know how to go about it. No experience in looping records.
Many Thanks in advance on this complicated matter.
Andy
Hi All,
I was wondering if anyone can help me in trying to write some vb code for the following purpose:
I want to loop through records until a quantity of 21 is reached then assign a value to a field then carry on with the loop.
If 21 can't be met 20 or 19 is OK but much be round up to the nearest number.
Example:
Record 1 - No of Lanes = 9.22222
Record 2 - No of Lanes = 14.11112
Record 3 - No of Lanes = 12.333328
Record 4 - No of Lanes = 8.7888954
So Value 0f the field I want to assign will be as follows:
1
2
3
4
So the formula should be something like
If record 1 = 21 then
assign value of 1 . If not then go to next record and add quantities together. If = 21 then assign value = 1 but must = 21 exactly . If quantities over 21 then create duplicate record and adjust quantity to balance (balance minus 21) on the duplicate record.
Then procede to the duplicate and then loop through the records has above until all data in table has been assigned a value in the required field.
I understand this could take time, just don't know how to go about it. No experience in looping records.
Many Thanks in advance on this complicated matter.
Andy
Last edited: