This will be Question 2.2 in the finals as from Finals 2018.
NOTE in the Exam Guidelines of 2021: "Pre-coded methods such as filter, sort and locate will NOT be allowed as coding in this regard must be done from first principles.".
The database will be linked to the program in the exam with or without a data module. We have better luck keeping the link if we open Delphi first and then opening the file using the .dpr from within Delphi.
Here are some pointers:
The learners usually have to display in a RichEdit and search for records using an If-Statement in a While loop. Remember that the .next should not be inside of the if-Statement or you will be stuck in an infinite loop. The only time that we place the .next in the else of an if-Statement is when we are looping to delete.
Using a while loop to search for items or add the values of a field to a ComboBox.
Ensure that the tbl.next is outside the if-statement but inside the while loop.
Remember pos can be used to search for partial string. This was handy in Exemplar 2018 Q 2.2.1
Remember that ADO tables are case sensitive, unlike SQL, and you will need uppercase in your condition when searching for strings.
Reading from both tables: Use the outer loop to search for the condition and the inner loop to search for the fields that are linked (PK - FK).
Edit - the Exemplar of 2018, made changes to the current active record. Active means that you do not need to search for a specific record but you will change whichever record is currently active. Remember the .post after the change has been made.
Delete:
When deleting multiple records ensure that you place the tbl.next in the else of the if where you are deleting. Failing to do this will mean that, when you have two records directly after each other, that needs to be deleted, you will skip over the second one.
Insert.
Note that it is not needed to use tbl.Last; before you insert.
The insert in the Exemplar of 2018 was using the current active record in the parent table to insert the foreign key.
If the insert asked to use hard code to insert the primary key and you click on the insert method twice, you will get an error since you are creating a duplicate primary key.
Remember the .post after adding the values to the fields.
If the question refers to the current active record - it means any record that is currently active in the table it refers to.
Using pos for partial search as in the Examplar 2018 Q 2.2.1