* You have to Requery and Refresh the combo after setting the * RowSource in code. Otherwise it causes resetting the field * value for the first record in the table to 0 as soon as you * issue .column1.CboProject.BoundTo = .t., as the CboProject.List * at that moment is still 0 .column1.CboProject.Requery() && [NN] added .column1.CboProject.Refresh() && [NN] addedWas finding that the first row's field value being set to zero. Nick's code corrected this. After replacing the one grid with a pageframe that holds 2 grids (one grid per page), I found that the grid highliting would not kick in unless i added the following in the form's INIT (not an issue prior to adding the pageframe):
thisform.pagetime.page1.grdtime.afterrowcolchange() thisform.pagetime.page2.grdtime.afterrowcolchange()I recommend his GridHighlighter, very easy to implement. The following code now works:
thisform.pagetime.page1.grdtime.recordsource = "TmpTime" thisform.pagetime.page2.grdtime.recordsource = "TmpTime" nDay = 0 WITH THISFORM.pagetime.page1.grdtime .column1.Controlsource = "tmptime.prjfk" .column1.header1.CAPTION = "Proj # / name" .column1.Cboproject.ColumnCount = 2 .column1.Cboproject.ColumnWidths = "150,0" * Version 1 - Original version. Somehow will not show the * value in the combobox when it is an active cell. * However, it keeps the original value in the table and shows * it again when another column activates *!* .column1.CboProject.rowsourcetype = 6 *!* .column1.CboProject.rowsource = "timeproj.prjdesc,prjpk" * Version2 - Nick's version. Works properly in all cases .column1.CboProject.rowsourcetype = 3 && - SQL Statement [NN] .column1.CboProject.rowsource = "select prjdesc,prjpk from timeproj order by prjdesc into cursor _cCboProject" ******** * You have to Requiery and Refresh the combo after setting the * RowSource in code. Otherwise it causes resetting the field * value for the first record in the table to 0 * as soon as you issue .column1.CboProject.BoundTo = .t., as the * CboProject.List at that moment is still 0 .column1.CboProject.Requery() && [NN] added .column1.CboProject.Refresh() && [NN] added .column1.CboProject.boundcolumn = 2 .column1.CboProject.boundto = .t. .column1.WIDTH = 150 .column2.CboCostCode.ColumnWidths = "55" .column2.WIDTH = 50 .column2.header1.CAPTION = "Cost" .column2.controlsource = "tmptime.costcodefk" .column2.CboCostCode.rowsourcetype = 6 .column2.CboCostCode.rowsource = "timecost.costcode" .column2.CboCostCode.ColumnCount = 1 * You have to Requery and Refresh the combo after setting the * RowSource in code. Otherwise it causes resetting the field * value for the first record in the table to 0 as soon as you * issue .column1.CboCostCode.BoundTo = .t., as the * CboCostCode.List at that moment is still 0 .column2.CboCostCode.Requery() && [NN] added .column2.CboCostCode.Refresh() && [NN] added .column2.CboCostCode.boundcolumn = 1 .column2.CboCostCode.boundto = .t. *** .column3.header1.CAPTION = "R or E" .column3.WIDTH = 35 .column3.CboRorE.boundto = .t. * [NN] Here you don't need to Requery/Refresh as the RowSource * is set in the Property Sheet. .column3.CboRorE.boundcolumn = 1 .column3.CboRorE.ColumnWidths = "35" .column3.controlsource = "tmptime.rore" xDateCntr = 0 nDay = 0 FOR x = 4 TO 17 * set the day columns 4-17 WIDTH, CAPTION, and CONTROLSOURCE values nDay = nDay + 1 cWidth = "column"+ALLTRIM(STR(x))+".width" .&cWidth = THISFORM.zDayColWidth cHeader = "column"+ALLTRIM(STR(x))+".header1.caption" cap = ALLTRIM(STR(nDay)) xDateCntr = xDateCntr + 1 .&cHeader = "&cap." cSource = "column"+ALLTRIM(STR(x))+".controlsource" cFie = "tmptime.R"+ALLTRIM(STR(nDay)) .&cSource = "&cFie" cFormat = "column"+ALLTRIM(STR(x))+".format" .&cFormat = "Z" ENDFOR FOR x = 1 TO 17 * make day columns 1-17 NOT resizable and NOT movable cCol = "column"+ALLTRIM(STR(x))+".resizable" .&cCol = .F. cCol = "column"+ALLTRIM(STR(x))+".movable" .&cCol = .F. ENDFOR .column18.WIDTH = 67 .column18.header1.CAPTION = "Month total" .column18.CONTROLSOURCE = "tmptime.rTotal" .column18.READONLY = .T. ENDWITH>Chris,
>l_return = .t. >IF BETWEEN(tmptime.projfk,1,10) > wait window "tmptime.projfk = "+ALLTRIM(STR(tmptime.projfk)) > l_return = .f. >ENDIF >RETURN l_return >>