AndrewMozley
Programmer
I want to create a drop-down combo class (amcombo) which lets the user select from a subset of records from a table. there would not be a great number of records in this subset - usually less than 100.
In skeletal form, the user would have mytable.dbf with these fields :
The combo would be interested only in records of a particular type, say those with RecTyp = “A”. Then whatever value is keyed into the combo could be used to further define which records are to be shown in the drop-down box. This would be different in each application, but one requirement would be to offer those records where the string entered into the combo say “AB” appears somewhere in MyCode or MyDesc.
To that end I plan to have these properties in this Combo Class
.zfile The alias of the table to be searched. In this case “MyTable"
.zKey The name of the keyfield. In this case “Mycode”
.zDesc The name of the description field. In this case “MyDesc”
.zFilter The string to filter the records. In this case “Rectyp = ‘A’”
Then, specific to the instance, the programmer would be able code some method (which one?) of the class to define which records to be offered. So (as above) if he decided that the user should be allowed to search from records with “AB” in the key or description by entering “#AB” into the combo, there would be code such as :
The questions which I have (apart from “Am I going about this the right way”?) include :
What should I set as the Rowsource of the combo; should I use the original MyTable, subject to a filter, or should I extract the records to a new cursor or array in the Init() method of amcombo?
Would I need to recreate a cursor or array each time the user specifies the group of records he is interested in (e.g. those containing “AB”)? Or would I do this by applying or modifying a filter?
Which methods of amcombo do I need to code to achieve the result.
I would mention that MyTable may well be used elsewhere on the form. In a particular example I am thinking of, I have a table of nominal account codes, some of which are bank accounts. So the user may be invited to select a bank account, while elsewhere on the form he may select from a wider range of accounts.
Thanks.
In skeletal form, the user would have mytable.dbf with these fields :
Code:
RecType C(1), MyCode C(6), MyDesc C(30)
The combo would be interested only in records of a particular type, say those with RecTyp = “A”. Then whatever value is keyed into the combo could be used to further define which records are to be shown in the drop-down box. This would be different in each application, but one requirement would be to offer those records where the string entered into the combo say “AB” appears somewhere in MyCode or MyDesc.
To that end I plan to have these properties in this Combo Class
.zfile The alias of the table to be searched. In this case “MyTable"
.zKey The name of the keyfield. In this case “Mycode”
.zDesc The name of the description field. In this case “MyDesc”
.zFilter The string to filter the records. In this case “Rectyp = ‘A’”
Then, specific to the instance, the programmer would be able code some method (which one?) of the class to define which records to be offered. So (as above) if he decided that the user should be allowed to search from records with “AB” in the key or description by entering “#AB” into the combo, there would be code such as :
Code:
IF LEFT(This.value,1) = “#”
lcSearch = RTRIM(SUBSTR(This.value,2))
. . . followed by some code either to set a filter or possibly extract records into a new cursor or array.
The questions which I have (apart from “Am I going about this the right way”?) include :
What should I set as the Rowsource of the combo; should I use the original MyTable, subject to a filter, or should I extract the records to a new cursor or array in the Init() method of amcombo?
Would I need to recreate a cursor or array each time the user specifies the group of records he is interested in (e.g. those containing “AB”)? Or would I do this by applying or modifying a filter?
Which methods of amcombo do I need to code to achieve the result.
I would mention that MyTable may well be used elsewhere on the form. In a particular example I am thinking of, I have a table of nominal account codes, some of which are bank accounts. So the user may be invited to select a bank account, while elsewhere on the form he may select from a wider range of accounts.
Thanks.