I have a form that is based on a dummy table (one with no records) Its a time clock program - the employee Scans their ID badge, it verifies have the correct person.
If the person is punched in - it punches them out, if they aren't punched in, it punches them in.
All of that works great.
My problem is no matter how I try to do it, the Variable that holds the Scan on the form (and this is the only field on the form) which on Activate and oninit I have it set the Variable to ""- doesn't always go back to blank.
The closest I came is it will with refreshing the form, except then it opens a second one and never closes the original one. So you could end up with 100 open with all the in/out all day. Running the Debug the Variable is set back to "", but when It goes to the form at the end of either if/else statement its not.
you can see with my commented out lines below the different steps I tried and none seem to work every time.
I even tried to just close the form and then would reopen it, but it won't close.
debug(1)
Dim tbl_time as P
Dim Indx_1 as P
dim ptr as P
'Dim Shared Emprecno as c
tbl_time = table.open("time")
Indx_1 = tbl_time.index_primary_put("TimeIn")
ptr = form.view("Time_Punch")
' Find Statement
rec = tbl_time.fetch_find(var->v_Emplno)
if (rec>0) then
tbl_time.change_begin()
tbl_time.date_out = Date()
tbl_time.time_out = time()
v_Emplno = ""
tbl_time.change_end(.t.)
tbl_time.close()
'ptr.Refresh()
':Time_Punch.close(.f.)
else
tbl_time.enter_begin()
tbl_time.employ_recno = v_Emplno
tbl_time.date_in = Date()
tbl_time.time_in = time()
v_Emplno = ""
tbl_time.enter_end(.t.)
tbl_time.close()
'ptr.Refresh()
':Time_Punch.close(.f.)
end if
ptr.Close(.f.)
debug(0)
If the person is punched in - it punches them out, if they aren't punched in, it punches them in.
All of that works great.
My problem is no matter how I try to do it, the Variable that holds the Scan on the form (and this is the only field on the form) which on Activate and oninit I have it set the Variable to ""- doesn't always go back to blank.
The closest I came is it will with refreshing the form, except then it opens a second one and never closes the original one. So you could end up with 100 open with all the in/out all day. Running the Debug the Variable is set back to "", but when It goes to the form at the end of either if/else statement its not.
you can see with my commented out lines below the different steps I tried and none seem to work every time.
I even tried to just close the form and then would reopen it, but it won't close.
debug(1)
Dim tbl_time as P
Dim Indx_1 as P
dim ptr as P
'Dim Shared Emprecno as c
tbl_time = table.open("time")
Indx_1 = tbl_time.index_primary_put("TimeIn")
ptr = form.view("Time_Punch")
' Find Statement
rec = tbl_time.fetch_find(var->v_Emplno)
if (rec>0) then
tbl_time.change_begin()
tbl_time.date_out = Date()
tbl_time.time_out = time()
v_Emplno = ""
tbl_time.change_end(.t.)
tbl_time.close()
'ptr.Refresh()
':Time_Punch.close(.f.)
else
tbl_time.enter_begin()
tbl_time.employ_recno = v_Emplno
tbl_time.date_in = Date()
tbl_time.time_in = time()
v_Emplno = ""
tbl_time.enter_end(.t.)
tbl_time.close()
'ptr.Refresh()
':Time_Punch.close(.f.)
end if
ptr.Close(.f.)
debug(0)
Comment