Show field value in form caption (1 Viewer)

JPR

Registered User.
Local time
Today, 12:54
Joined
Jan 23, 2009
Messages
192
Hello,
I know this may look strange but is there a way I can add the value of a control (ex. a value of a textbox) in the forms' Caption field from the Property Sheet?
Thank you
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 03:54
Joined
May 7, 2009
Messages
19,169
what do you mean?
you can add code to the textbox afterupdate event to set the caption of the form.
you can also add code to the form's current event to set the caption.
 

JPR

Registered User.
Local time
Today, 12:54
Joined
Jan 23, 2009
Messages
192
Hello and thank you for your quick reply.
I was thinking of making my form more effective by changing the normal text we type in the Caption line (generally is the form's name) with a value that is showing in a text box.
In my case, I would like to show the last name of the selected client. This record is stored in a textbox named txtLName.

Thanks
 

Minty

AWF VIP
Local time
Today, 19:54
Joined
Jul 26, 2013
Messages
10,355
As Arnel has suggested simply set the form caption on current event;

Screen.ActiveForm.Caption = "Flibble" or
Screen.ActiveForm.Caption = Me.txtLName
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 03:54
Joined
May 7, 2009
Messages
19,169
as I have said you can add code to the Form's current event and on the textbox afterupdate event.
bring your form in design view.
on property sheet, select from the combobox, Form.
on the Event tab, On Current, choose Code Builder.
Code:
Private Sub Form_Current()
    Me.Caption = Me.txtLName & ""
End Sub
save and run your form.

again, select txtLName from the combobox on property sheet.
on the Event tab, After Update, choose Code Builder.
Code:
Private Sub txtLName_AfterUpdate()
    Me.Caption = Me.txtLName & ""
End Sub
 

JPR

Registered User.
Local time
Today, 12:54
Joined
Jan 23, 2009
Messages
192
Perfect. Working great. Thanks
 

Users who are viewing this thread

Top Bottom