Results 1 to 5 of 5
  1. #1
    4 Star Lounger
    Join Date
    May 2002
    Location
    Roanoke, Virginia, USA
    Posts
    493
    Thanks
    0
    Thanked 0 Times in 0 Posts

    DLookup (A2K SP3)

    I am having a problem with a DLookup. When the operator opens frmCheckInLast and enters the room number, it displays the last rental record of the guest. If the correct information is displayed, the operator then clicks the New Record button to extend the stay of the guest. The new form is displayed with some of the data filled in based on the record just reviewed.

    The operator this enters the PayPeriod from a pull down menu. At this point the Lookup fails with an error message

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: DLookup (A2K SP3)

    The latter form
    <code>
    Me.RoomRate = DLookup("Rate", "tblRoomRates", "RoomTypeID = " & _
    Me.RoomTypeID & " AND PayCodeID = " & Me.PayCodeID)
    </code>
    works OK when I try it. If it doesn't for you, try this variation:
    <code>
    Me.RoomRate = DLookup("Rate", "tblRoomRates", "RoomTypeID = " & _
    Me!RoomTypeID & " AND PayCodeID = " & Me!PayCodeID)</code>

  3. #3
    4 Star Lounger
    Join Date
    May 2002
    Location
    Roanoke, Virginia, USA
    Posts
    493
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: DLookup (A2K SP3)

    Many thanks. The secord version solved the problem.

    Tom

  4. #4
    4 Star Lounger SteveH's Avatar
    Join Date
    Jan 2001
    Location
    Chelsea, Gtr London, United Kingdom
    Posts
    587
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: DLookup (A2K SP3)

    I think (HansV will correct me if i'm wrong I'm sure) that the reason that the first expression did not work is because you have named your controls the same as the underlying data field. If you use the prefixes txt for textboxes etc. it should help Access distinguish between the textbox and the underlying field.

    Bang (!) means a member of a collection. Dot means the property of a form. The field in a record source and a textbox on a form are both properties of that form. If they have the same name then Access cannot distinguish between them - hence a good reason for using the LNR naming convention for your controls.

    <post#=79,643>post 79,643</post#> gives a fuller descrition of the difference between bang and dot as well.
    Steve H
    IT Lecturer/Access Developer
    O2K SR3/O2010; Win7Pro

  5. #5
    4 Star Lounger
    Join Date
    May 2002
    Location
    Roanoke, Virginia, USA
    Posts
    493
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: DLookup (A2K SP3)

    Thanks for the added information. I will pay more attention to the LNR nanaming conventions in the future.

    Tom

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •