lookforsmt
Registered User.
- Local time
- Today, 11:44
- Joined
- Dec 26, 2011
- Messages
- 672
HI! all I hope everyone is safe and sound,
i have the below code on variant, how can i improve the code when i have say 10 variants and and 10 different ControlSource and other logic remains the same. Can anyone help with to provide me a better solution.
I had the below code from my earlier project which i want to amend the code based on the current requirement. Help with Template
i have the below code on variant, how can i improve the code when i have say 10 variants and and 10 different ControlSource and other logic remains the same. Can anyone help with to provide me a better solution.
I had the below code from my earlier project which i want to amend the code based on the current requirement. Help with Template
Code:
Private Sub ClaimedAmount_AfterUpdate()
Dim x As Double, y As Double, z As Double
Dim a As Double, b As Double, c As Double
Dim var As Variant
Dim var1 As Variant
If Nz(Me.cboSRSubType, "") = "" Then
Me.NR1.ControlSource = ""
Else
x = Me.ChqAmount
y = Me.ClaimedAmount
z = x - y
If Me.Claim & "" <> "Cleared" Then _
Me.Claim.Value = Switch(z > 0, "Short", z = 0, "Cleared", True, "Excess")
var = DLookup("RuleID & '|' & NR1", "tbl_Rules", "Rule1='" & Me.cboSRSubType & "' And Rule2='" & Me.cboSRSubSubType & "' And Claim='" & Me.Claim & "'")
Me.RulesID = CLng(Split(var, "|")(0))
Me.NR1.ControlSource = "=" & Split(var, "|")(1)
End If
'----------------------------var1----------------------------
If Nz(Me.cboSRSubType, "") = "" Then
Me.VR1.ControlSource = ""
Else
a = Me.ChqAmount
b = Me.ClaimedAmount
c = a - b
If Me.Claim & "" <> "Cleared" Then _
Me.Claim.Value = Switch(c > 0, "Short", c = 0, "Cleared", True, "Excess")
var1 = DLookup("RuleID & '|' & VR1", "tbl_Rules", "Rule1='" & Me.cboSRSubType & "' And Rule2='" & Me.cboSRSubSubType & "' And Claim='" & Me.Claim & "'")
Me.RulesID = CLng(Split(var1, "|")(0))
Me.VR1.ControlSource = "=" & Split(var1, "|")(1)
End If
End Sub