So...I've wrote up a block of code calculating the total charge of a sale. However, it doesn't seem to be working, as whenever I try running the form, MS Access returns with a:
Runtime error '2465' - System can't find the field '|1' referred to in your expression.
The below is my code - it's pretty self explanatory, but I'd be happy to run you through each line if it's hard to understand:
Thanks!
Runtime error '2465' - System can't find the field '|1' referred to in your expression.
The below is my code - it's pretty self explanatory, but I'd be happy to run you through each line if it's hard to understand:
Code:
Private Sub Form_Current()
Dim AdultPrice As Integer
Dim ChildPrice As Integer
Dim InfantPrice As Integer
Dim AdultsPrice As Integer
Dim ChildrenPrice As Integer
Dim InfantsPrice As Integer
Dim BaseRatePrice As Integer
Dim BaseMultiplier As Integer
Dim AccommodationType As String
Dim Duration As Integer
If Me.Peak_Period.Value = "Yes" Then
AdultPrice = DLookup("BaseRate", "Base Rates", "Label = '" & "Adult - Peak" & "'")
ChildPrice = DLookup("BaseRate", "Base Rates", "Label = '" & "Child - Peak" & "'")
Else
AdultPrice = DLookup("BaseRate", "Base Rates", "Label = '" & "Adult" & "'")
ChildPrice = DLookup("BaseRate", "Base Rates", "Label = '" & "Child" & "'")
End If
InfantPrice = DLookup("BaseRate", "Base Rates", "Label = '" & "Infant" & "'")
AdultsPrice = [Me.Adults.Value] * AdultPrice
ChildrenPrice = [Me.Children.Value] * ChildPrice
InfantsPrice = [Me.Infants.Value] * InfantPrice
BaseRatePrice = AdultsPrice + ChildrenPrice + InfantsPrice
AccommodationType = DLookup("AccommodationType", "Accommodations", "Accommodation ID = '" & Me.Accommodation.Value & "'")
BaseMultiplier = DLookup("BaseMultiplier", "Accommodation Types", "Label = '" & AccommodationType & "'")
Duration = DateDiff("d", [Arrival Date], [Departure Date]) + 1
Me.Charge.Value = BaseRatePrice * BaseMultiplier * Duration
Thanks!
Comment