Hello Everybody. I am trying to use DLookup but failing. I am making a booking sytem for a theatre and have a seatID table and a Booking table. I have a dropdown menu on my booking form that has all the seats in. This form also has a "Cost" field. What I want is when a seat ID is selected from the drop down menu, the price of that seat is displayed in the "Cost" field. This value is retrieved from the Seat table that has seat ID and price in. I started out with this code:
Private Sub SeatIDCombo_AfterUpdate()
Cost = DLookup("Price", "tblSeat", "SeatID=" & SeatID)
End Sub
I was getting "the runtime error 2001" and it was telling me that I "canceled the previous operation." I fixed this with the code below:
Private Sub SeatID_AfterUpdate()
Price = DLookup("Price", "tblSeat", "SeatID=" & "SeatID")
End Sub
Now I get no errors. However, the Dlookup is now returning exactly the same value regardless of the seat ID selected (which obviously shouldn't be the case as in the seat table, the seat ID's have different prices attatched to them).
Please Please Please help me sort this out. It's literally driving me insane
Thanks hugely in advance
I have now realised that the Dlookup is returning the first value in the seat table for all seatID's. Why would it be returning the first value of price for all seat ID's???