Koot,
To expand on Steve's reply a little. On your line:
else thisform.txtNhours.value = nHour"
every thing past the ELSE is being interpretted as a
comment. Once the VFP parser has determined it has a valid command it ignores everything else on the line (it's an old thing
(and quite crappy thing IMHO) in FoxPro that allowed end of line comments before we got the &&. VFP is expecting ELSE to be it's own line of code and thus the real code you are trying to get executed doesn't run.
restructure it like this and all will be well:
if nHour > wHour
thisform.txtNhours.value = wHour
else
thisform.txtNhours.value = nHour"
endif
>Hi All
>I used the following code to calculate certain hours worked but the ELSE statement gets ignored. All the values are correct.
>There is some calculations before this.
>
>" wHour = (45 - hHour)
> nHour = (thetot.sum_hours - (thetot.sum_shifts - dshift.sum_shifts))
> if nHour > wHour
> thisform.txtNhours.value = wHour
> else thisform.txtNhours.value = nHour"
>Only when nHour was > than wHour did it work right that left me to conclude
>that the else statment gets ignored.
>
>I then changed it to this which solved my problem.
> nHour = (thetot.sum_hours - (thetot.sum_shifts - dshift.sum_shifts))
> if nHour > wHour
> thisform.txtNhours.value = wHour
> endif
> if nHour < wHour
> thisform.txtNhours.value = nHour
> endif
>
>I would just like to know if anybody can shed some ligth on this
>
>Thanx
>Koot Coetzer