Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

entry in field in browse do not get updated..

Status
Not open for further replies.

pareshrdoshi

Programmer
Jul 1, 2014
5
IN
hello. i am using foxpro 2.6 for dos. i have following problem.

- i have a PAYMENT.DBF file which has 3 fields : P_Date D, party_name C (30), amt n (12, 2)

- my PAY.PRG file contains following commands :
use PAYMENT
T_Date = iif (.not. eof (), Date, ctod (''))
on key label f1 do repl_dt
on key label f2 do store_dt
browse fields date, party_name, amt freeze date
on key label f1
on key label f2
close all
clear all
return
- i have to procedures in same prg file.
PROC REPL_DT
replace P_Date with T_Date
return

PROC STORE_DT
T_Date = P_Date
return

- here objective is to replace P_Date with T_Date by pressing F1
- and T_Date can be replaced by current P_Date by pressing F2.
- it works well unless in following circumstances
e.g. P_Date = 06/09/2013 - when user is manually changing p_date
by just changing first 2 characters of P_Date to '07'. now p_date
shows as 07/09/2013. ENTER key is not yet pressed, so field is not
"exited". now if I press F2, then I want T_Date to have value of changed
P_Date i.e. 07/09/2013 - but it remains 06/09/2013 only. It may be
possible as i have not exited the P_Date field by pressing ENTER.
- so I have changed procedure store_dt routine as follows :
PROC STORE_DT
keyboard '{ENTER}'
T_Date = P_Date
- still T_Date gets old value of P_Date. The value of P_Date (and then
value of T_Date gets changed only when i press ENTER key manually and
then i press F2.
- is there any sollution to this problem. i.e. user just changes 1 or 2
chars of date, and presses F2 and new P_Date should get stored in T_Date ?
i mean if user do not press ENTER, then can we use "keyboard {ENTER}" ?

- if you guys can solve my problem, i will be highly grateful.

regards,
paresh
 
You should probably flush the change to p_date immediately after the REPLACE as it may not have been written to disk before the value in the table is stored to t_date.

PROC REPL_DT
replace P_Date with T_Date
FLUSH
return

And hitting 'ENTER' before changing a field won't work on the current field. The cursor would have moved past it.

PROC STORE_DT
T_Date = P_Date
keyboard '{ENTER}'


-Dave Summers-
[cheers]
Even more Fox stuff at:
 
As you've noticed, you MUST leave a field for the value in that field to be written to the table.

Your KEYBOARD doesn't do anything because Foxpro won't "use" the keystroke until it gets to the next wait state. So force a wait state:

Keyboard '{ENTER}'
READ TIMEOUT .01

(You may also need a VALID .T. on that READ command. It's been a lotta years since I had to deal with this one.)
 
Also, PLEASE use any other keystroke combination.

The F1 key has been reserved for Help for something like 20 years.
 
freinds,

** problem solved. **

- thanks for helping. i found a bypass way to sovle this problem
- the problem was :
when you are changing a part of a field in browse, but did not come out of the field,
(by pressing enter / page down / control+w, tab etc.) and if you check the value of
that field, it used to show original value. i.e. value before editing and not the
current value at the time of edit.
e.g. a P_Date field : 01/06/2014 - now you are editing it and typed '02' in place of '01'
but you are still in that field, and if you run any procedure (by way of on key label...),
then in that procedure you get original value (before you went for edit) i.e. : 01/06/2014
but i wanted the current value, which is : 02/06/2014
- the sollution is as follows :
i re-wrote PROC STORE_DT as follows :

PROC STORE_DT
T_Date = P_Date
@ 20,20 say "Is This Ok : ? " get ans pict 'Y' defa 'Y'
read
T_Date = P_Date

- Bingo !!! the problem solved and i got the updated P_Date value.
- so somehow a get has to be terminated manually and not thru "keyboard" command.

- thanks a lot : danfreeman - for igniting a spark for the solution.

regards,
paresh doshi
 
freinds,

a small correction. PROC STORE_DT should be as follows :

*----------------------------------*
PROC STORE_DT

@ 20,20 say "Is This Ok : ? " get ans pict 'Y' defa 'Y'
read
T_Date = P_Date

return
*----------------------------------*
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top