Hi all, was wondering if you could take a quick look at this section of code for me. I use this code as part of a diary it is called each time an appointment is made to scan the table diary to see if the client is available. I have put a dummy record in my diary table so that even when the diary could be empty there is something to scan. Though I have a record in my table to mark the client as unavailable during a specific time of a specific date only on the first occurance of running this code the appointment is not recognising the client unavailable record and the client appointment is saved, on the second try of saving an appointment on that same day the appointment (as it should be) will not save as the client is unavailable. If I close the system down and run it again the appointment checking program works fine so it just seems to be when i have one dummy record and the first time I check the diary.
* check the clients availabilty if we are wanting to save a client appointment, check if the client is already scheduled for an appointment or if they are unavailable
if Client_id != -1
select 'diary'
go top
* locate for appointment == client_id and where the new appointment date/time falls between an existing
* appointments date/time within diary.dbf. Check that you do not include cancelled or deleted appointments
SCAN FOR diary.client_no == Client_id and BETWEEN(starttime,diary.start_time,diary.end_time) and diary.cancelled == .F. and !deleted()
* make sure the user is not updating an existing appointment
if found() and diary.support_no != App_id
if starttime == diary.end_time
* if the start time follows on from and end time assign .T.
Client_Accepted = .T.
else
* the appointment times are taken for the client assign .F.
Client_Accepted = .F.
endif
endif
ENDSCAN
* locate for appointment == client_id and where the new appointment date/time proceeds and exceeds an existing
* appointment within diary.dbf. Check that you do not include cancelled or deleted appointments
select 'diary'
go top
SCAN FOR diary.client_no == Client_id and starttime < diary.start_time and endtime > diary.start_time and diary.cancelled == .F. and !deleted()
* make sure the user is not updating an existing appointment
if found() and diary.support_no != App_id
* the appointment times are taken for the tutor assign .F.
Client_Accepted = .F.
endif
ENDSCAN
endif
* check the clients availabilty if we are wanting to save a client appointment, check if the client is already scheduled for an appointment or if they are unavailable
if Client_id != -1
select 'diary'
go top
* locate for appointment == client_id and where the new appointment date/time falls between an existing
* appointments date/time within diary.dbf. Check that you do not include cancelled or deleted appointments
SCAN FOR diary.client_no == Client_id and BETWEEN(starttime,diary.start_time,diary.end_time) and diary.cancelled == .F. and !deleted()
* make sure the user is not updating an existing appointment
if found() and diary.support_no != App_id
if starttime == diary.end_time
* if the start time follows on from and end time assign .T.
Client_Accepted = .T.
else
* the appointment times are taken for the client assign .F.
Client_Accepted = .F.
endif
endif
ENDSCAN
* locate for appointment == client_id and where the new appointment date/time proceeds and exceeds an existing
* appointment within diary.dbf. Check that you do not include cancelled or deleted appointments
select 'diary'
go top
SCAN FOR diary.client_no == Client_id and starttime < diary.start_time and endtime > diary.start_time and diary.cancelled == .F. and !deleted()
* make sure the user is not updating an existing appointment
if found() and diary.support_no != App_id
* the appointment times are taken for the tutor assign .F.
Client_Accepted = .F.
endif
ENDSCAN
endif