Changing the title on a form with VB

  • Thread starter Thread starter John Ortt
  • Start date Start date
J

John Ortt

I am trying to use a single form to display the data from a number of
queries.
I have now got this aspect working but I would like to change the title of
the form depending on the Query used for it's source data. I have a text
box at the top of the form entitled "Title".
I am trying to use the following line of code to change it but it doesn't
work, does anybody know how to make it work please.

Forms.VendorExpectedMarginsReport.Title.Text = "Cost Selling Report"

Thanks.

John.

P.S. The full section of code follows incase it is of any use.
________________________

Option Compare Database
Option Explicit
Dim stDocName As String
Dim stLinkCriteria As String

Function Open_VMForm()
stDocName = "VendorExpectedMarginsReport"
DoCmd.Openform stDocName, , , stLinkCriteria
End Function

Private Sub Button2_Click()
Open_VMForm
Forms.VendorExpectedMarginsReport.Title.Text = "Cost Selling Report"
Forms.VendorExpectedMarginsReport.RecordSource = "Select_Cost_Selling"
End Sub
 
John

Another approach might be to use a text control on the form and fill that
with whatever you want to see.
 
Would the code I have written then work Jeff?

If not what would I have to use?

Thanks Again for your Reply,

John
 
John

Generically, what I would do is have a "title" control available on the
form, a way to know/get what needed to be in it (say, as one of the columns
in a combo box), and code that says something like:

Me!txtTitle = Me!cboComboBox.Column(n)

where the Column(n) points at the (zero-based count) column in the combo
box's underlying query.
 
John said:
I am trying to use a single form to display the data from a number of
queries.
I have now got this aspect working but I would like to change the title of
the form depending on the Query used for it's source data. I have a text
box at the top of the form entitled "Title".
I am trying to use the following line of code to change it but it doesn't
work, does anybody know how to make it work please.

Forms.VendorExpectedMarginsReport.Title.Text = "Cost Selling Report"


In addition to Jeff's suggestions, don't use the Text
property. In Access, you want to use the Value property.

Me.Title = "Cost Selling Report"
 
Back
Top