Checking a Status Control from a Form Before Proceeding

A

Ange Kappas

Hi,
I have a code which performs certain functions, but I want to
add to it extra code which will stop it proceeding if a value in a field is
not satisfactory.
There is a form based on a query (qryDepartures) which has a field called
"Status". The only values in this field is either IN or OUT. If the field is
showing IN for whatever record I want the code to STOP and Go To the
qryDepartures Form so I can change the value to OUT.

The code is:

Private Sub Toggle1_Click()
Dim PoseidonHotelProgram As Database
Dim rsta As DAO.Recordset
Dim frm As Form
Dim Msg, Style, Title, Response, MyString

Set db1 = CurrentDb()
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

End Sub

What can I add to it to secure the above.

Any help is appreciated !!

Thanks
Ange
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top