Auto-Title from Comvo box

andrewghunt

Registered User.
Local time
Today, 07:26
Joined
Jan 16, 2009
Messages
10
Hi, I have a combo box that is used to select which record you are viewing on a form, how can I make the name selected from the combo box automatically appear as the form title, in a Label box?
 
In the on change event of your Combo put the following;
Code:
Me.YourLabelName.Caption = Me.YourComboName.Column([B][COLOR="Purple"]x[/COLOR][/B]) [COLOR="Green"]'Replace the x with the column number you want as the caption[/COLOR]

Remember that the columns in a combo are numbered from Zero up.

You may also want to put some code in the OnLoad event of the form and also the OnCurrent event of the form to handle the situation where a selection has not been made in the Combo, and assign a caption accordingly.
 
Thank you sir, good idea :D
 
Actually you can't place a label on the Form Title Bar, but you can assign it directly to the title bar using Me.Caption. I used this for an app I did a while back, where ClientName is the field I want to display in the Form Title Bar.

Code:
Private Sub Form_Current()
 If Me.NewRecord Then
  Me.Caption = "Entering New Record"
 Else
  Me.Caption = "Active Client Record for: " & ClientName
End If
End Sub
It'll work whether you use the combobox to retrieve the record or simply scroll thru your records.
 

Users who are viewing this thread

Back
Top Bottom