I am using a dialog box with 2 dbcombos as a trip calculator.
The user chooses an origin and drop point and that is where I want some text or perhaps a MsgAlert() to display a calculated
km value - within the dialog to calc as many times as needed without having to start the dialog again.
I' ve tried variations of ON CHANGE oKm:seek or a say clause on the calc button, but I have to activate the dialog to do the calc and the MsgAlert() will appear with the km. I'm obviously coding it wrong.
oTcomp holds the company longnames and cod(code) fields which then are seeked in oKm
oTkm has a combination of 2 cod(company codes) with a fixed km value for that trip.
Help
Bruce S
FW 6/12
Harbour v3.1 Rev 17222
ilinl32 6.21
//--------
.dbfs set here
DEFINE DIALOG oDlg FROM -50, 15 TO -35, 75 ;
TITLE " Trip Distance Calculator"
@ .5, 6 SAY "&Origin" OF oDlg SIZE 22, 11
@ 21, 8 dbcombo oDBC1 var cOrg of oDlg;
alias oTcomp:cAlias;
size 100,250 pixel;
itemfield "COD" ;
listfield "COMP";
update;
@ .5, 26 SAY "&Drop" OF oDlg SIZE 22, 11
@ 21, 128 dbcombo oDBC1 var cDrp of oDlg;
alias oTcomp:cAlias;
size 100,250 pixel;
itemfield "COD" ;
listfield "COMP";
update;
@ 3,12 say 'Minimum trip fee - $ ' + trans(nMin,'99.99');
FONT fntArial SIZE 125,25 OF oDlg
@ 5, 11 BUTTON "&Calc" OF oDlg SIZE 40, 12 ACTION oDlg:End() //Say( 6, 2, cOrg + ' / '+ cDrp + ' ' )
@ 5, 21 BUTTON "&Exit" OF oDlg SIZE 40, 12 ACTION oDlg:End()
ACTIVATE DIALOG oDlg CENTERED
If oTkm:seek(cOrg+cDrp) = .t.
nKm := KM
nCost := iif(nKm * ( nL_rate + nFactor) < nMin, nMin,nKm * ( nL_rate + nFactor) )
MsgInfo( space(2)+ trans(nKm,'999.99') + " km = " +;
" $ " + trans(nCost,'9999.99')+ space(3)," Trip cost")
else
If empty(cOrg) .or. empty(cDrp)
MsgInfo(" Incomplete trip data ")
Else
MsgInfo(" That trip data was not found ")
Endif
Endif
fntArial:End()
return nil