View Full Version : Selecting a record from a query


petebevans
06-09-2008, 11:49 AM
I have developed a database which uses a form with a combo box (unbound) to select PatientHospitalNo (Primary Key) from the PatientDetailsTable and display patient information in this form and patient treatment episodes in a sub form. The customer has decided that they would prefer to select a patient by name rather than by hospital no. In order not to have to modify the existing form too much and to reduce the chance of selecting the wrong patient with the same name, I created a form launched by a command button on the main form. This form displayed the results of a query on a specific patient name, returning their date of birth and hospital no. What I wanted to do was to be able to select the correct record from this query and on closing the form input the PatientHospitalNo into the combo box on the main form. I don't want to add the record to the combo source as it already exists. Rather I want it to put the required PatientHospitalNo into the combo box as if I had manually selected that record from the combo box. Is this possible to do or is there another solution? :confused:

Pat Hartman
06-10-2008, 07:35 PM
You need to use an unbound combo for searching. In the afterUpdate of the combo, position the form to the selected record.

Access will create what you need if you add a new combo to the form. Just choose the option to find a record on this form. The popup form needs to populate this combo and then it needs to requery the form so that the selected record will be displayed.

petebevans
07-14-2008, 07:09 AM
Thanks for that Pat. Easy when you know how isn't it? Sorry for delay in replying - life has been rather hectic!