Changing the title on a form with VB

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
 
J

Jeff Boyce

John

Another approach might be to use a text control on the form and fill that
with whatever you want to see.
 
J

John Ortt

Would the code I have written then work Jeff?

If not what would I have to use?

Thanks Again for your Reply,

John
 
J

Jeff Boyce

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.
 
M

Marshall Barton

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"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top