(Source Code) Foxpro - Showing POPUP with values from database

Foxpro/VFP Source Codes

 Foxpro - Showing POPUP with values from database


* this program of foxpro is using POPUP for selection of Department Name from the database.
* it will validate for valid department code also.

close all
set safe off
use dept in 0
scatt memv blank
define wind w1 from 10,10 to 20,40
define popup p1 prompt fields dept.dname
on selection popu p1 do p2
on key label f1 do acti_pop
@4,5 say "Enter dept"
@4,20 get m.dno1 defa 0
@5,5 say "Enter dept"
@5,20 get m.dno valid check_dept()
@5,40 say "Press f1 for selection"
@6,20 get m.dname disa
read

proc acti_pop
***************
activ wind w1
acti popu p1
m.dno = dept.dno
show get m.dno
m.dname = dept.dname
show get m.dname


proc p2
************
hide wind w1
deac popu p1


proc check_dept
*****************
sele dept
index on alltrim(dno) tag dno
set order to dno
if not seek(alltr(m.dno)) then
 wait wind "Invalid dept"
 return 0
else
 m.dname = dept.dname
 show get m.dname
endif
return 1