A
Ange Kappas
Hi All,
I have a code which runs ok, when there is a value in my
QUERY called "qryDEPARTURES" but when the QUERY has no value on certain days
it stops on the line below:
If Myset5![STATUS] = "IN" Then
how can I make it continue when the query returns no values.
The code is:
Private Sub Toggle8_Click()
Dim PoseidonHotelProgram As Database
Dim rsta As DAO.Recordset
Dim frm As Form
Dim Msg, Style, Title, Response, MyString
Set db1 = CurrentDb()
Set Myset5 = db1.OpenRecordset("qryDEPARTURES")
If Myset5![STATUS] = "IN" Then
Msg = "There Are Still Departures as 'IN'"
Style = vbOK + vbInformation + vbDefaultButton1 ' Define buttons.
Title = "DEPARTURES PENDING" ' Define title.
Response = MsgBox(Msg, Style, Title)
DoCmd.OpenForm "DEPARTURES", acNormal
Else
Msg = "CONFIRM CLOSE DAY YES to Continue NO to Change/Edit Transaction ?"
' Define message.
Style = vbYesNo + vbInformation + vbDefaultButton1 ' Define buttons.
Title = "FINALIZE CLOSE DAY" ' Define title.
Response = MsgBox(Msg, Style, Title)
If Response = vbYes Then ' User chose Yes.
MyString = "Yes" ' Perform some action.
Set Myset = db1.OpenRecordset("TODAY CHARGES")
Set Myset2 = db1.OpenRecordset("RESPEL ALL CHARGES")
Set Myset4 = db1.OpenRecordset("RUNDATE")
With Myset
If Not .EOF Then
.MoveFirst
End If
Do While Not .EOF
Myset2.AddNew
Myset2![Date] = Myset![Date]
Myset2![PELNMB] = Myset![PELNMB]
Myset2![RESNO] = Myset![RESNO]
Myset2![RESNAME] = Myset![RESNAME]
Myset2![COMPANY] = Myset![COMPANY]
Myset2![PRICELIST] = Myset![PRICELIST]
Myset2![HOTELAPT] = Myset![HOTELAPT]
Myset2![ROOMNO] = Myset![ROOMNO]
Myset2![ROOMTYPE] = Myset![ROOMTYPE]
Myset2![BASIS] = Myset![BASIS]
Myset2![ARRIVAL] = Myset![ARRIVAL]
Myset2![DAYS] = Myset![DAYS]
Myset2![DEPARTURE] = Myset![DEPARTURE]
Myset2![SURNAME] = Myset![SURNAME]
Myset2![NAME] = Myset![NAME]
Myset2![DAILY CHARGE] = IIf(Myset![PRICELIST] = "Z", Myset![DAILY CHARGE],
Myset![Price])
Myset2.Update
..MoveNext
Loop
End With
Myset2.Close
Myset4.MoveLast
Myset4.Delete
Myset4.AddNew
Myset4![Date] = Me![NEW DATE]
Myset4.Update
Myset4.Close
DoCmd.OpenQuery "UPDATE STATUS RESPEL ALL CHARGES"
DoCmd.OpenQuery "UPDATE STATUS RESERVATIONS"
Else
MyString = "No" ' Perform some action.
DoCmd.OpenForm "MAIN MENU"
End If
End If
End Sub
Any help much appreciated
Ange
I have a code which runs ok, when there is a value in my
QUERY called "qryDEPARTURES" but when the QUERY has no value on certain days
it stops on the line below:
If Myset5![STATUS] = "IN" Then
how can I make it continue when the query returns no values.
The code is:
Private Sub Toggle8_Click()
Dim PoseidonHotelProgram As Database
Dim rsta As DAO.Recordset
Dim frm As Form
Dim Msg, Style, Title, Response, MyString
Set db1 = CurrentDb()
Set Myset5 = db1.OpenRecordset("qryDEPARTURES")
If Myset5![STATUS] = "IN" Then
Msg = "There Are Still Departures as 'IN'"
Style = vbOK + vbInformation + vbDefaultButton1 ' Define buttons.
Title = "DEPARTURES PENDING" ' Define title.
Response = MsgBox(Msg, Style, Title)
DoCmd.OpenForm "DEPARTURES", acNormal
Else
Msg = "CONFIRM CLOSE DAY YES to Continue NO to Change/Edit Transaction ?"
' Define message.
Style = vbYesNo + vbInformation + vbDefaultButton1 ' Define buttons.
Title = "FINALIZE CLOSE DAY" ' Define title.
Response = MsgBox(Msg, Style, Title)
If Response = vbYes Then ' User chose Yes.
MyString = "Yes" ' Perform some action.
Set Myset = db1.OpenRecordset("TODAY CHARGES")
Set Myset2 = db1.OpenRecordset("RESPEL ALL CHARGES")
Set Myset4 = db1.OpenRecordset("RUNDATE")
With Myset
If Not .EOF Then
.MoveFirst
End If
Do While Not .EOF
Myset2.AddNew
Myset2![Date] = Myset![Date]
Myset2![PELNMB] = Myset![PELNMB]
Myset2![RESNO] = Myset![RESNO]
Myset2![RESNAME] = Myset![RESNAME]
Myset2![COMPANY] = Myset![COMPANY]
Myset2![PRICELIST] = Myset![PRICELIST]
Myset2![HOTELAPT] = Myset![HOTELAPT]
Myset2![ROOMNO] = Myset![ROOMNO]
Myset2![ROOMTYPE] = Myset![ROOMTYPE]
Myset2![BASIS] = Myset![BASIS]
Myset2![ARRIVAL] = Myset![ARRIVAL]
Myset2![DAYS] = Myset![DAYS]
Myset2![DEPARTURE] = Myset![DEPARTURE]
Myset2![SURNAME] = Myset![SURNAME]
Myset2![NAME] = Myset![NAME]
Myset2![DAILY CHARGE] = IIf(Myset![PRICELIST] = "Z", Myset![DAILY CHARGE],
Myset![Price])
Myset2.Update
..MoveNext
Loop
End With
Myset2.Close
Myset4.MoveLast
Myset4.Delete
Myset4.AddNew
Myset4![Date] = Me![NEW DATE]
Myset4.Update
Myset4.Close
DoCmd.OpenQuery "UPDATE STATUS RESPEL ALL CHARGES"
DoCmd.OpenQuery "UPDATE STATUS RESERVATIONS"
Else
MyString = "No" ' Perform some action.
DoCmd.OpenForm "MAIN MENU"
End If
End If
End Sub
Any help much appreciated
Ange