Results 1 to 6 of 6
  1. #1
    Alex Motilal is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Nov 2008
    Location
    Coimbatore, India
    Posts
    192

    Error 2766

    RoomTariffs.zipHello everybody,

    I am developing a Hotel Room Booking Database. I created a function to pull the Room Tariff applicable on the booking date. However, when the query is run it shows error # 2766. I have attached the file for analysis. Please tell what I have done wrong.

    Alex

  2. #2
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    The text of the error should give you a hint. You didn't concatenate the RoomType variable into the string.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Alex Motilal is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Nov 2008
    Location
    Coimbatore, India
    Posts
    192
    Thanks for the reply pbaldy.
    Still I could not solve the problem. The RoomNature field as you can see is an Integer field. Can you please solve and upload the database for me?
    Alex

  4. #4
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I'm on the road for another hour. You have to concatenate that variable into the string the same way you did the other. No delimiters since it's numeric.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    Alex Motilal is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Nov 2008
    Location
    Coimbatore, India
    Posts
    192

    Smile Error 2766

    I changed the function and Query SQL as follows:

    Function:

    Public Function RoomRateChargeable(BookedDt As Date, RoomNbr As String) As Double

    RoomRateChargeable = DLookup("[RoomTariff]", "[QryTariffs]", "[DtFrom]<= #" & BookedDt & "# And Nz([DtTo],#12/31/9999#)>= #" & BookedDt & "# And [RoomNumber]='" & [RoomNbr] & "'")

    End Function

    Created New Qry: QryTariffs - SQL:

    SELECT tblRoomNo.RoomNumber, tblTariffs.RoomTariff, tblTariffs.DtFrom, tblTariffs.DtTo
    FROM (tblRmNature INNER JOIN tblRoomNo ON tblRmNature.RmNatureID = tblRoomNo.RoomNature) INNER JOIN tblTariffs ON tblRmNature.RmNatureID = tblTariffs.RoomNature;

    Query1 SQL:

    SELECT tblBooking.GuestName, tblRoomNo.RoomNumber, tblRmNature.RmNatureID, tblBooking.CheckInDt, tblBooking.CheckOutDt, RoomRateChargeable([CheckInDt],[RoomNumber]) AS RmTariff
    FROM tblRmNature INNER JOIN (tblRoomNo INNER JOIN tblBooking ON tblRoomNo.RoomNumber = tblBooking.RoomBooked) ON tblRmNature.RmNatureID = tblRoomNo.RoomNature;

    This solved my problem.

    Alex

  6. #6
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Glad you got it sorted out.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 03-27-2012, 01:40 PM
  2. Compile Error Syntax Error
    By Mohamed in forum Access
    Replies: 3
    Last Post: 10-06-2011, 10:12 AM
  3. Replies: 6
    Last Post: 09-28-2011, 09:20 PM
  4. Error 2501 displays with Error handling
    By agent- in forum Programming
    Replies: 13
    Last Post: 08-05-2011, 02:20 PM
  5. Replies: 8
    Last Post: 05-16-2011, 06:01 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums