Run-time error '2465' - System can't find the field '|1'

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • SourceOfAccess
    New Member
    • Nov 2015
    • 6

    Run-time error '2465' - System can't find the field '|1'

    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:

    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!
    Last edited by Rabbit; Dec 2 '15, 04:34 PM. Reason: Please use [code] and [/code] tags when posting code or formatted data.
  • mbizup
    New Member
    • Jun 2015
    • 80

    #2
    What line of code does it fail on? (ie: which line is highlighted when you click the 'Debug' button in the error message popup?)

    Comment

    • mbizup
      New Member
      • Jun 2015
      • 80

      #3
      You should drop the brackets in your control references...

      AdultsPrice = [Me.Adults.Value] * AdultPrice

      should be:

      AdultsPrice = Me.Adults.Value * AdultPrice

      etc.. for the other similar lines.

      Comment

      Working...