hi,
I've got code to calculate shipping costs in a VB module. This code is now run from a Macro that worked perfectly before.
If the user clicks "Calculate Total" on the forum then everything runs fine. If they change a qty or price, recalculate the total it fails where I assign the shipping cost in the forum.
this is my code
On the pass after a change is made it seems to fail on these
lines
The [S&H] is a combo box not limited to list on the form. It is a bound form.
Any suggestions would be great, thanks.
I've got code to calculate shipping costs in a VB module. This code is now run from a Macro that worked perfectly before.
If the user clicks "Calculate Total" on the forum then everything runs fine. If they change a qty or price, recalculate the total it fails where I assign the shipping cost in the forum.
Code:
error 2448: You can't assign a value to this object
this is my code
Code:
Function setShipping(ByVal Country, ByVal code)
'Country tells us which form to populate
'code tells us which source Code to use
'get source code from form
'check if postage has value
'if postage has value it is FSI and set S/h
'else set the s/h according to the price structure specified (using price scale)
Dim postage As Variant
Dim shipCode As Variant
Dim shipping As Double
postage = DLookup("PostageTable", "Clearpoint Source Code Set-up Database", "[Source Code] = '" & code & "'")
If IsNull(postage) = True Then
shipCode = DLookup("[SH Structure]", "Clearpoint Source Code Set-up Database", "[Source Code] = '" & code & "'")
If (shipCode = 1) Then
If UCase(Country) = "CANADA" Then
shipping = Switch(Forms![CLEARPOINT CAN DATABASE FORM]![Text350] <= 14.99, 3.95, Forms![CLEARPOINT CAN DATABASE FORM]![Text350] <= 24.99, 4.95, Forms![CLEARPOINT CAN DATABASE FORM]![Text350] <= 49.99, 5.95, Forms![CLEARPOINT CAN DATABASE FORM]![Text350] >= 50, 6.95)
Forms![CLEARPOINT CAN DATABASE FORM]![S&H] = shipping
Else
shipping = Switch(Forms![CLEARPOINT USA DATABASE FORM]![Text350] <= 14.99, 3.95, Forms![CLEARPOINT USA DATABASE FORM]![Text350] <= 24.99, 4.95, Forms![CLEARPOINT USA DATABASE FORM]![Text350] <= 49.99, 5.95, Forms![CLEARPOINT USA DATABASE FORM]![Text350] >= 50, 6.95)
Forms![CLEARPOINT USA DATABASE FORM]![S&H] = shipping
End If
Else
If UCase(Country) = "CANADA" Then
shipping = Switch(Forms![CLEARPOINT CAN DATABASE FORM]![Calculated Order Amount] <= 14.99, 5.95, Forms![CLEARPOINT CAN DATABASE FORM]![Calculated Order Amount] <= 24.99, 6.95, Forms![CLEARPOINT CAN DATABASE FORM]![Calculated Order Amount] <= 34.99, 7.95, Forms![CLEARPOINT CAN DATABASE FORM]![Calculated Order Amount] <= 44.99, 8.95, Forms![CLEARPOINT CAN DATABASE FORM]![Calculated Order Amount] <= 54.99, 9.95, Forms![CLEARPOINT CAN DATABASE FORM]![Calculated Order Amount] <= 64.99, 10.95, Forms![CLEARPOINT CAN DATABASE FORM]![Calculated Order Amount] <= 74.99, 11.95, Forms![CLEARPOINT CAN DATABASE FORM]![Calculated Order Amount] >= 75, 12.95)
Forms![CLEARPOINT CAN DATABASE FORM]![S&H] = shipping
Else
shipping = Switch(Forms![CLEARPOINT USA DATABASE FORM]![Calculated Order Amount] <= 14.99, 5.95, Forms![CLEARPOINT USA DATABASE FORM]![Calculated Order Amount] <= 24.99, 6.95, Forms![CLEARPOINT USA DATABASE FORM]![Calculated Order Amount] <= 34.99, 7.95, Forms![CLEARPOINT USA DATABASE FORM]![Calculated Order Amount] <= 44.99, 8.95, Forms![CLEARPOINT USA DATABASE FORM]![Calculated Order Amount] <= 54.99, 9.95, Forms![CLEARPOINT USA DATABASE FORM]![Calculated Order Amount] <= 64.99, 10.95, Forms![CLEARPOINT USA DATABASE FORM]![Calculated Order Amount] <= 74.99, 11.95, Forms![CLEARPOINT USA DATABASE FORM]![Calculated Order Amount] >= 75, 12.95)
Forms![CLEARPOINT USA DATABASE FORM]![S&H] = shipping
End If
End If
Else
If UCase(Country) = "CANADA" Then
Forms![CLEARPOINT CAN DATABASE FORM]![S&H] = postage
Else
Forms![CLEARPOINT USA DATABASE FORM]![S&H] = postage
End If
End If
End Function
On the pass after a change is made it seems to fail on these
Code:
Forms![CLEARPOINT USA DATABASE FORM]![S&H] = shipping
lines
The [S&H] is a combo box not limited to list on the form. It is a bound form.
Any suggestions would be great, thanks.
Last edited: