View Single Post
Old Aug 19th, 2005, 11:09 AM   #32
gj15987
Programmer
 
Join Date: Feb 2005
Posts: 45
Rep Power: 0 gj15987 is on a distinguished road
Quote:
Originally Posted by DaWei
Stop and think about what you're doing, and stop and think about providing useful information in your posts.

Sounds like proper operation to me....
Yes I was just showing that the outer if works.

I've followed it through many times and it seems fine to me, yet when i enter a valid employee ID it somehow freezes, and i can't figure out where it gets stuck in the loop.

Here's how I interpret it if i enter a valid employee number and i already have a shift thats clocked in: (how i interpret it is in bold)

procedure Tfrm_clock_In.btn_enterClick(Sender: TObject);
var
          Today:TDateTime;
          Executed:boolean;
begin
Executed:= false;
Today:= Date;
tbl_employees.Open;
tbl_employees.First;
Repeat
        if strtoint(Edit_Employee_ID.text) = tbl_employeesEmployee_ID.value then // it will find the employee number in the employee table
            begin
                tbl_shift.Open;
                tbl_shift.First;
                repeat
                        if (strtoint(Edit_Employee_ID.text) = tbl_shiftEmployee_ID.value) and (tbl_shiftDate_.Value = Today) then // this is also true as its the only record i have in the shift table
                           begin
                                if Datetostr(tbl_shiftTime_Out.value)='' then // The time out field is blank so it will updaet the record and then set executed to true                                        
                                       begin
                                                //sql to updae file with clock out time
                                                showmessage('Clocked Out');
                                                Executed:=true;
                                        end
                                else Tbl_shift.Next;
                           end
                        else tbl_shift.Next;
                Until (Executed=true) or (tbl_shift.Eof); //executed is now true so the loop finishes           
             end 
        else tbl_employees.Next;
Until (Executed=true) or (tbl_employees.Eof); // again executed is true so this loop also ends
end;
gj15987 is offline   Reply With Quote