1 (edited by eyeman303 2021-07-04 16:04:38)

Topic: Configure a label or form caption

Hello,
I want to have the patient name displayed in the form F2_opd_record, either as a label (Label4) or as the form caption. How to get the full name of the patient displayed?
Regards,
Eyeman

Post's attachments

Attachment icon clinic _label.zip 475.14 kb, 183 downloads since 2021-07-04 

2 (edited by derek 2021-07-04 18:01:14)

Re: Configure a label or form caption

Hi There Eyeman.
Please have a look at the attached which does (I think!) what you're after (specifically lines 3-22 in the script).
It is not quite so straightforward because you call f2_opd_record from 2 discrete places (f1_patients_record (when adding) and d3_opd_register (when editing)) and so you need to build the f2_opd_record caption differently depending on where you're starting from.
If you are going to use the caption like this, I think you should probably do it consistently on all of your forms where it's applicable.  So, for example, you could do it on f4_clinics_record as well.  And in the case of f4_clinics_record, you could then also append the OPDid after the patient full name.
Any questions, just shout.
Derek.

Post's attachments

Attachment icon eyeman fullname.zip 495.17 kb, 208 downloads since 2021-07-04 

Re: Configure a label or form caption

Hello Derek,
I am enriched once again with your lucid explanation and script. This is what I have been trying to achieve. Though no more required in this project, can the label4 inside the form be configured in a similar way? Thanks a lot!
Regards,
Eyeman

Re: Configure a label or form caption

Hi,
Yes, you can do exactly the same thing with any label (see attached - in the script I've commented out the lines that put the patient's name in the form caption and added lines to put the patient's name in the appropriate label caption instead.
Regards,
Derek.

Post's attachments

Attachment icon eyeman fullname 2.zip 495.45 kb, 217 downloads since 2021-07-04 

Re: Configure a label or form caption

Hello Derek,
Thanks again. Now I understand the principle, how to create label caption and form caption. Surely, this learning will be useful in other projects too!
Regards,
Eyeman

6 (edited by eyeman303 2021-07-07 18:36:38)

Re: Configure a label or form caption

Hello Derek,
While applying the above principle in another similar project, I am getting an inconsistent result when editing the record by clicking the edit button in the form DB_Form_002_LIST_OPD_VISIT_REGISTER. For some records, the full name is displayed in the (edit) form caption, while for others it is not. Cannot make out why this is happening. However, while adding a new record or editing a record while clicking buttons in AA_Form_006_PATIENT_REG_REC form, the AA_Form_007_OPD_VISIT_REC form is captioned correctly. Please help.(photos attached)
Regards,
Eyeman

Post's attachments

Attachment icon Form_caption.zip 414.54 kb, 189 downloads since 2021-07-07 

Re: Configure a label or form caption

Hello Eyeman,
I imagine it's because AA_Form_007_OPD_VISIT_REC is called from 2 different places.
If you upload your full project (minus the .exe) then I can try and have a look.
Derek.

Re: Configure a label or form caption

Hello Derek,
Can you please have a look at my project?
Regards,
Eyeman

Post's attachments

Attachment icon My_Eyes_59.zip 523 kb, 219 downloads since 2021-07-08 

9 (edited by derek 2021-07-09 23:47:33)

Re: Configure a label or form caption

Hi Eyeman,
Thanks for attaching your project but I can't run it on my machine (you've got more than 150 tables and 130 forms and it just hangs);  I hope you've got a PC that can run your project without too much delay!
But I was able to have a look at the script and also at the data in your tables (using SQLiteStudio) and I think what is happening is that in your 'select' statement, you are not checking for firstname and/or middlename and/or lastname being blank.  If any of your records has any of these fields missing, the AA_Form_007_OPD_VISIT_REC caption won't get filled.
As a quick test, try adding middlename to one or two of the records and see if that fixes it.
If it does, then replace the existing section in your script with the following which tests for 'null' in the fields you're trying to join:
.
procedure DB_Form_002_LIST_OPD_VISIT_REGISTER_Button5_OnClick (Sender: TObject; var Cancel: boolean);
begin
  AA_Form_007_OPD_VISIT_REC.Caption := sqlexecute('select ifnull(First_name,"")||" "||ifnull(middle_name,"")||" "||ifnull(Last_name,"") from AA_001_REC_PATIENT_REG where id = (select id_AA_001_REC_PATIENT_REG from AA_002_REC_Visits where id = "'+DB_Form_002_LIST_OPD_VISIT_REGISTER.TG_VISIREC_LIST.sqlvalue+'")');
end;
.
I think this will fix your problem but, as I say, I've not been able to get your program to run to be able to prove it.
Derek.

Re: Configure a label or form caption

Hello Derek,
You are spot-on! You have rightly identified the problem being, possible null value(s)  in First_Name or Middle_Name or Last_Name fields. Your script works perfectly, giving desired output. Sorry to know that the program did not run on your PC. It takes a little time to open on my PC, but thereafter works smoothly. I thank you a thousand times and cannot express my gratitude enough.
Regards,
Eyeman

Post's attachments

Attachment icon photos.zip 202.23 kb, 200 downloads since 2021-07-10