Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Table not updating from calculated/conditional form values

Status
Not open for further replies.

wlwoman

Technical User
Jul 8, 2001
133
US
I have a table with a number of fields that update based on the initial and secondary value selections. The updated values work as designed, except when the form is closed, those fields are not updated in the underlying table.

Example:
Selection #1 = "CaseSize"
Selection #2 = "Shifts"

Code is as follows:
1
Private Sub CaseSize_AfterUpdate()

If CaseSize = "S" Then
TOT = 22
PcsPerBlk = 6300
Value = 1
Shift1PerStationUnitsPerHour = 6
ElseIf CaseSize = "F" Then
TOT = 25
PcsPerBlk = 3400
Value = 2
Shift1PerStationUnitsPerHour = 5
.....etc.

2
Private Sub Shifts_AfterUpdate()
If Shifts = 1 Then
Shift2PerStationUnitsPerHour = 0
Else: Shift2PerStationUnitsPerHour = RotaryShift1PerStationUnitsPerHour]
End If
End Sub

Everything is fine up to this point; the fields mentioned in the code update the corresponding table fields. After that it just doesn't work.

Next field is "Shift1PerStationUnitsPerShift" and the control source is "=([CastingShift1PerStationUnitsPerShift]*7)"

The math works but the table is never updated from this field or any others like it.

I have no idea what I've done wrong since I'm relatively new to all of this; I can generate a direct report from the form which displays all of the calculated values, but the table fields for these values are all equal to "0".


 
Let me answer my own question (which somehow threw the switch after reading it in vivid color!):

I have to add the formulas to my VB code rather than to the form control source, and change the form control source back to the related table field. All is well (duh!); I should sleep more?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top