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

    Populating Fields (A2K SR3)

    I have frmCheckIn where the operator enters a room number and an After Update Event looks up the room rate and displays the appropriate room type from tblRoomType.

    TblRoomType has 2 fields RoomTypeID and RoomType. TblRental also has a RoomTypeID field that has a lookup from qryRoomTypeSorted whose source is tblRoomType.

    The After Update Event is as follows:

    Private Sub RoomNumber_AfterUpdate()
    If IsNull(Me.Room) Then
    Me.RackRate = Null
    Me.RoomRate = Null
    ElseIf Not IsNull(Me.PayCodeID) Then
    Me.RoomRate = DLookup("Rate", "tblRoomRates", "RoomTypeID = " & Me.RoomTypeID & " AND PayCodeID = " & Me.PayCodeID)
    If Me.DoubleOccupancy Then
    Me.RoomRate = Me.RoomRate + Me.Extra
    End If
    Me.RackRate = Me.RoomRate
    End If
    End Sub

    I want to store the RoomTypeID (RoomType?) in tblRental. I tried adding the following after Me.RackRate=MeRoomRate

    Me.[tblRental].[RoomTypeID] = Me.[TblRoom].[RoomTypeID}

    The lookup in the RoomTypeID in tblRental has me confused.


    Tom

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

    Re: Populating Fields (A2K SR3)

    What is the record source of frmCheckIn?

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

    Re: Populating Fields (A2K SR3)

    The record source is qryRentCalc0.

    RentCalc0 has the following objects
    tblRental
    tblRoom
    qryMarketingsorted
    qryCustomerSorted
    tblPropertyNames
    tblRoomType
    tblPayCode


    Tom

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

    Re: Populating Fields (A2K SR3)

    Why do you want to store the room type in tblRental? It can be derived from the room number, if I understand your description correctly.

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

    Re: Populating Fields (A2K SR3)

    What I am looking for is a tempory quick fix. I have just modiifed the database to be able to derive the room type from the room number. I need to do an extensive review and eventually delete the RoomTpye from tblRental.

    In the meantime I looking for a temporary fix.

    Thanks.

    Tom

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

    Re: Populating Fields (A2K SR3)

    You could give the two room type id fields in qryRentCalc0 different aliases, e.g. RoomTypeID_Rental and RoomTypeID_Room. You can then use

    Me.RoomTypeID_Rental = Me.RoomTypeID_Room

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

    Re: Populating Fields (A2K SR3)

    In RentCalc0 I set up 2 new fields:
    RoomTypeID_Rental:[tblRental]![RoomTypeID}
    RoomTypeID_Room:[tblRoom]![RoomTypeID]

    I then added
    Me.RoomTypeID_Rental = Me.RoomTypeID_Room
    To the After Update event

    When I enter the room number, .RoomTypeID_Room is highlighted with a Compile error: Method or data member not found.


    Tom

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

    Re: Populating Fields (A2K SR3)

    Have you created controls (hidden, if preferred) with those names?

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

    Re: Populating Fields (A2K SR3)

    I had put the 2 control on the form but failed to properly name them. This solved the error problem.

    The control RoomTypeID_Room displays the proper number but RoomTypeID_Rental is blank. Does the fact that tblRental.RoomTypeID is a lookup have a bearing on the problem? If you dislplay tblRental.RoomTypeID it displays the RoomType from the lookup not the RoomTypeID number.

    Tom

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

    Re: Populating Fields (A2K SR3)

    I don't think I can help without seeing (a stripped down copy of) the database.

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

    Re: Populating Fields (A2K SR3)

    As requested, I am attaching a copy of the database. Open frmCustomerEntry and then Press Check In button. An existing customer can be selected by using the pull down nemu.

    Thanks for your assistance.


    Tom

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

    Re: Populating Fields (A2K SR3)

    The instruction

    Me.RoomTypeID_Rental = Me.RoomTypeID_Room

    is only executed if PayCodeID is not null. As long as PayCodeID is blank, RoomTypeID_Rental will not be populated. Try this:

    Private Sub RoomNumber_AfterUpdate()
    If IsNull(Me.Room) Then
    Me.RackRate = Null
    Me.RoomRate = Null
    Else
    If Not IsNull(Me.PayCodeID) Then
    Me.RoomRate = DLookup("Rate", "tblRoomRates", "RoomTypeID = " & _
    Me.RoomTypeID_Room & " AND PayCodeID = " & Me.PayCodeID)
    If Me.DoubleOccupancy Then
    Me.RoomRate = Me.RoomRate + Me.Extra
    End If
    Me.RackRate = Me.RoomRate
    End If
    Me.RoomTypeID_Rental = Me.RoomTypeID_Room
    End If
    End Sub

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

    Re: Populating Fields (A2K SR3)

    Many thanks as usual. This sovled the problem

    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
  •