A
Abby B via AccessMonster.com
I put the following code in the after update event of a field. It is supposed
to update two fields but it doesn't do anything! Can anyone advise please. I
think it has to do with the if statment structure! I have three conditions
for each case and a different output in each. thanks.
Private Sub region_AfterUpdate()
If [region] = "ON" And [RMA/74PI] = "74PI" And [74pi] < 9 Then
[rma#] = "ON1010" & [74pi]
[CostCentre] = "30365"
If [region] = "ON" And [RMA/74PI] = "74PI" And [74pi] > 9 Then
[rma#] = "ON10" & [74pi]
[CostCentre] = "30365"
If [region] = "ON" And [RMA/74PI] = "74PI" And [74pi] > 99 Then
[rma#] = "ON1" & [74pi]
[CostCentre] = "30365"
If [region] = "ON" And [RMA/74PI] = "74PI" And [74pi] > 999 Then
[rma#] = "ON" & [74pi]
[CostCentre] = "30365"
Else
If [region] = "QR" And [RMA/74PI] = "74PI" And [74pi] < 9 Then
[rma#] = "QC1010" & [74pi]
[CostCentre] = "30366"
If [region] = "QR" And [RMA/74PI] = "74PI" And [74pi] > 9 Then
[rma#] = "QC10" & [74pi]
[CostCentre] = "30366"
If [region] = "QR" And [RMA/74PI] = "74PI" And [74pi] > 99 Then
[rma#] = "QC1" & [74pi]
[CostCentre] = "30366"
If [region] = "QR" And [RMA/74PI] = "74PI" And [74pi] > 999 Then
[rma#] = "QC" & [74pi]
[CostCentre] = "30366"
Else
If [region] = "WE" And [RMA/74PI] = "74PI" And [74pi] < 9 Then
[rma#] = "WE1010" & [74pi]
[CostCentre] = "30366"
If [region] = "WE" And [RMA/74PI] = "74PI" And [74pi] > 9 Then
[rma#] = "WE10" & [74pi]
[CostCentre] = "30366"
If [region] = "WE" And [RMA/74PI] = "74PI" And [74pi] > 99 Then
[rma#] = "WE1" & [74pi]
[CostCentre] = "30366"
If [region] = "WE" And [RMA/74PI] = "74PI" And [74pi] > 999 Then
[rma#] = "WE" & [74pi]
[CostCentre] = "30366"
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End Sub
to update two fields but it doesn't do anything! Can anyone advise please. I
think it has to do with the if statment structure! I have three conditions
for each case and a different output in each. thanks.
Private Sub region_AfterUpdate()
If [region] = "ON" And [RMA/74PI] = "74PI" And [74pi] < 9 Then
[rma#] = "ON1010" & [74pi]
[CostCentre] = "30365"
If [region] = "ON" And [RMA/74PI] = "74PI" And [74pi] > 9 Then
[rma#] = "ON10" & [74pi]
[CostCentre] = "30365"
If [region] = "ON" And [RMA/74PI] = "74PI" And [74pi] > 99 Then
[rma#] = "ON1" & [74pi]
[CostCentre] = "30365"
If [region] = "ON" And [RMA/74PI] = "74PI" And [74pi] > 999 Then
[rma#] = "ON" & [74pi]
[CostCentre] = "30365"
Else
If [region] = "QR" And [RMA/74PI] = "74PI" And [74pi] < 9 Then
[rma#] = "QC1010" & [74pi]
[CostCentre] = "30366"
If [region] = "QR" And [RMA/74PI] = "74PI" And [74pi] > 9 Then
[rma#] = "QC10" & [74pi]
[CostCentre] = "30366"
If [region] = "QR" And [RMA/74PI] = "74PI" And [74pi] > 99 Then
[rma#] = "QC1" & [74pi]
[CostCentre] = "30366"
If [region] = "QR" And [RMA/74PI] = "74PI" And [74pi] > 999 Then
[rma#] = "QC" & [74pi]
[CostCentre] = "30366"
Else
If [region] = "WE" And [RMA/74PI] = "74PI" And [74pi] < 9 Then
[rma#] = "WE1010" & [74pi]
[CostCentre] = "30366"
If [region] = "WE" And [RMA/74PI] = "74PI" And [74pi] > 9 Then
[rma#] = "WE10" & [74pi]
[CostCentre] = "30366"
If [region] = "WE" And [RMA/74PI] = "74PI" And [74pi] > 99 Then
[rma#] = "WE1" & [74pi]
[CostCentre] = "30366"
If [region] = "WE" And [RMA/74PI] = "74PI" And [74pi] > 999 Then
[rma#] = "WE" & [74pi]
[CostCentre] = "30366"
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End Sub