philips44
10-12-2008, 09:19 AM
hello,
I'm trying to build a hotel automation application and got stuck with the the reservation part as follows: there are two combo boxes in a form followed by a code to determine the price from a table. However I get no match whatsoever even though I have displays values from both form and table side. I believe that my IF cycle is not working properly and appreciate any help.
Note: I have tried If ... then... else and keep getting error also I need to repeat the If's for Double, Triple, Suite, etc.. room types.
Thank you
Private Sub Combo50_AfterUpdate()
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim isValid As Boolean
Set db = Access.Application.CurrentDb
Set rst = db.OpenRecordset("SELECT * FROM seasons ", dbOpenDynaset)
' >>>>>>>>>>>>>>> check if both dates are not null <<<<<<<<<<<<<<<<<<<<<<<
If Not (IsDate(arrivaldate)) Then Exit Sub
If Not (IsDate(cikistarihi)) Then Exit Sub
' >>>>>>>>>>>>>>> open table and start comparing >>>>>>>>>>>>>>>>>>>>>>>>>
With rst
.MoveLast
.MoveFirst
Do While .EOF = False
If rst!tourname = Form![Combo50] And Form![Text59] = "Single" And arrivaldate > rst!season1startdate And _
checkoutdate < rst!season1enddate And arrivaldate > rst!season1startdate And checkoutdate < rst!season1enddate Then
nightprice = rst!season1singleprice & MsgBox("case 1 true")
End If
If rst!tourname = Form![Combo50] And Form![Text59] = "Single" And arrivaledate > rst!season2startdate And _
chekoutdate < rst!season1enddate And giristarihi > rst!season2startdate And checkoutdate < rst!season2enddate Then
nightprice = rst!season2singleprice And MsgBox("case 2 true")
End If
If rst!tourname = Form![Combo50] And Form![Text59] = "Single" And arrivaldate > rst!season2startdate And _
checkoutdate < rst!season1enddate And arrivaldate > rst!season3startdate And cikistarihi < rst!season3enddate Then
nightprice = rst!season3singleprice And MsgBox("case 3 true")
End If
MsgBox (rst!tourname)
.MoveNext
Loop
End With
Set rst = Nothing
Set db = Nothing
End Sub
I'm trying to build a hotel automation application and got stuck with the the reservation part as follows: there are two combo boxes in a form followed by a code to determine the price from a table. However I get no match whatsoever even though I have displays values from both form and table side. I believe that my IF cycle is not working properly and appreciate any help.
Note: I have tried If ... then... else and keep getting error also I need to repeat the If's for Double, Triple, Suite, etc.. room types.
Thank you
Private Sub Combo50_AfterUpdate()
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim isValid As Boolean
Set db = Access.Application.CurrentDb
Set rst = db.OpenRecordset("SELECT * FROM seasons ", dbOpenDynaset)
' >>>>>>>>>>>>>>> check if both dates are not null <<<<<<<<<<<<<<<<<<<<<<<
If Not (IsDate(arrivaldate)) Then Exit Sub
If Not (IsDate(cikistarihi)) Then Exit Sub
' >>>>>>>>>>>>>>> open table and start comparing >>>>>>>>>>>>>>>>>>>>>>>>>
With rst
.MoveLast
.MoveFirst
Do While .EOF = False
If rst!tourname = Form![Combo50] And Form![Text59] = "Single" And arrivaldate > rst!season1startdate And _
checkoutdate < rst!season1enddate And arrivaldate > rst!season1startdate And checkoutdate < rst!season1enddate Then
nightprice = rst!season1singleprice & MsgBox("case 1 true")
End If
If rst!tourname = Form![Combo50] And Form![Text59] = "Single" And arrivaledate > rst!season2startdate And _
chekoutdate < rst!season1enddate And giristarihi > rst!season2startdate And checkoutdate < rst!season2enddate Then
nightprice = rst!season2singleprice And MsgBox("case 2 true")
End If
If rst!tourname = Form![Combo50] And Form![Text59] = "Single" And arrivaldate > rst!season2startdate And _
checkoutdate < rst!season1enddate And arrivaldate > rst!season3startdate And cikistarihi < rst!season3enddate Then
nightprice = rst!season3singleprice And MsgBox("case 3 true")
End If
MsgBox (rst!tourname)
.MoveNext
Loop
End With
Set rst = Nothing
Set db = Nothing
End Sub