AndrewMozley
Programmer
I would like to have a form myform which displays a grid mygrid of customer accounts (from table XCUST) from which I can let the user select one. The customer table exists on entry to the form, but the range of customers does not, because I let the user specify criteria which limit the range of customers (name beginning with . . . . &c)
So the form has a grid defined with 3 columns, with a RecordSource csrThese; this last is the name of the cursor which will exist, once the form has done its stuff. The control sources of the columns (or possibly of their Text1 fields) are left as default, because the form will not load if the grid has an invalid control source of one of its elements.
I have this rather crude code in myform.Init().
PARAMETERS vString
WITH Thisform
SELECT ID, Account, common_name, Postcode FROM XCUST ;
WHERE .T. INTO CURSOR csrThese
* Eventually we pay attention to the search
* WHERE vString $ SearchKey INTO CURSOR csrThese
IF RECCOUNT("csrThese") = 0
.zReturn = 0
.cmdClose.Click()
ENDIF
* We couldn’t set the control properties of the grid within the definition
* of the form, because cursor doesn’t exist when form is first displayed.
WITH .grdThese
.Column1.ControlSource = "csrThese.Account"
* .Column1.Text1.ControlSource = "csrThese.Account"
ENDWITH
.grdThese.Refresh()
ENDWITH
RETURN DODEFAULT()
However I find that (although the grid is displayed) no records are shown (at this stage I would like just the account number in Column1). I have put a breakpoint into the code, and cursor csrThese has several records.
What do I need to do, please?
I was also confused that both the Column and its Text1 property have a control source. Why is this? I had thought that the property that I want is a link to the field in Cursor csrThese. If however I set the Text1.controlsource to the field in my csrThese table, the command is rejected at run-time.
Thanks. Andrew
So the form has a grid defined with 3 columns, with a RecordSource csrThese; this last is the name of the cursor which will exist, once the form has done its stuff. The control sources of the columns (or possibly of their Text1 fields) are left as default, because the form will not load if the grid has an invalid control source of one of its elements.
I have this rather crude code in myform.Init().
PARAMETERS vString
WITH Thisform
SELECT ID, Account, common_name, Postcode FROM XCUST ;
WHERE .T. INTO CURSOR csrThese
* Eventually we pay attention to the search
* WHERE vString $ SearchKey INTO CURSOR csrThese
IF RECCOUNT("csrThese") = 0
.zReturn = 0
.cmdClose.Click()
ENDIF
* We couldn’t set the control properties of the grid within the definition
* of the form, because cursor doesn’t exist when form is first displayed.
WITH .grdThese
.Column1.ControlSource = "csrThese.Account"
* .Column1.Text1.ControlSource = "csrThese.Account"
ENDWITH
.grdThese.Refresh()
ENDWITH
RETURN DODEFAULT()
However I find that (although the grid is displayed) no records are shown (at this stage I would like just the account number in Column1). I have put a breakpoint into the code, and cursor csrThese has several records.
What do I need to do, please?
I was also confused that both the Column and its Text1 property have a control source. Why is this? I had thought that the property that I want is a link to the field in Cursor csrThese. If however I set the Text1.controlsource to the field in my csrThese table, the command is rejected at run-time.
Thanks. Andrew