Mike is right. However, to get you off the ground, here is a possible way to populate a grid with selected records from a table.
Suppose you have an open table with the ALIAS
customer. The fields of this table include the customer’s name
Custname, his
Account code, a
Postcode and the outstanding
Balance on the account.
Create a new form with a textbox
txtPrefix, into which the user will enter the first few characters of the customer name (its Format property should be ‘!’ – without the quotes); a command button
cmdSearch with caption ‘Search’; and a grid
grdresult with its Colcount property set to 4 and its Deletemark set to .F..
Then in the
Click() method of
cmdSearch, place code something like this :
Code:
LOCAL lPrefix
WITH Thisform
lPrefix = RTRIM(.txtPrefix.value)
SELECT Account, Custname, Postcode, Balance ;
FROM Cus WHERE UPPER(Cus.custname) = lPrefix INTO CURSOR cSubset
.grdResult.RecordSource = "cSubset"
.grdResult.Refresh()
ENDWITH
You could include code after the SELECT statement to check that there was at least one record in the cursor
cSubset which you have created.
If the rule for extracting records to be placed in
grdresult was a little more complicated, you could equally replace the SELECT-SQL statement above with statements to create an empty cursor and then populate it with a SCAN through the Customer table.
I hope this helps. Good luck Su.
Andrew