Re: Nested If problem

Tech-Archive recommends: Speed Up your PC by fixing your registry



Carrie

I didn't spot anything right off, but here are a couple ideas... (I'm
assuming "Action" is a combo box - see below).

First, create a procedure behind the form that is not connected to any of
the controls.

Next, for readability, consider using the Select Case command, something
like:

Private Sub RecalcInspectionFrequency()

If (Me!cboAction = Suspend) Then
Select Case Me!Risk_Level
Case "Low"
If Me!Risk_Type Between 1 and 4 Then
Me!Inspection_Frequency = 5
ElseIf Me!Risk_Type = 5 Then
Me!Inspection_Frequency = 1
Else
'?any other conditions to test
End If
Case "Medium"
If Me!Downhole_Option =1 Then
Me!Inspection_Frequency = 3
ElseIf Me!Downhole_Option Between 2 And 3 Then
Me!Inspection_Frequency =5
Else
'?are there any other option values?
End If
Case "High"
If Me!Downhole_Option =1 Then
Me!Inspection_Frequency = 1
ElseIf Me!Downhole_Option = 2 Then
Me!Inspection_Frequency =5
Else
'?are there any other option values?
End If
Case Else
Me!Inspection_Frequency =0
End Select
End If 'test "Suspend

After you create this, call it from the AfterUpdate event of each/every one
of the controls that contribute to the decision. That way, when something
changes in a control, the recaculation is done.

Regards

Jeff Boyce
Microsoft Office/Access MVP



.


Quantcast