Changing title on form based on what is filtered

T

tsison7

I have a form where the title can be either "Delivery Reports: Customers X"
or "Delivery Reports: Customers Y".

When a command button is pressed I set a variable "customer" to 1 for
Customers X and to 2 for Customers Y depending on which command button is
pressed.

Since the forms are identical I want to use the same form but have the title
change depending on which Customers X or Y it is for.

I've set the title to "=iif(customer =1,"Delivery Reports: Customers
X","Delivery Reports: Customers Y))". But all it shows up with is "Name?"

I also had to define "customer" as a Public Variable.

I can get it to work using a function like:

Public Function getmyvariablecustomer() As String
getmyvariabletitle = customer
End Function

and rewriting the statement as =iif(getmyvariablecustomer()=1,.....)

But that seems like the wrong way to go about it....is it?
 
A

Al Campagna

tsison7,
I think there's a much easier way to change a title (TextControl) on on a
form according to how it was opened.
Use the OpenArgs portion of the OpenForm Method.
Use
=[OpenArgs ]
as the ControlSource of your Title field.

Use 2 different OpenForm methods to open each form
DoCmd.OpenForm "frmYourFormX", , , , , , "Customer X"
and
DoCmd.OpenForm "frmYourForm", , , , , , "Customer Y"
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."
 
T

tsison7

Thanks, Al very helpful
--
TIA


Al Campagna said:
tsison7,
I think there's a much easier way to change a title (TextControl) on on a
form according to how it was opened.
Use the OpenArgs portion of the OpenForm Method.
Use
=[OpenArgs ]
as the ControlSource of your Title field.

Use 2 different OpenForm methods to open each form
DoCmd.OpenForm "frmYourFormX", , , , , , "Customer X"
and
DoCmd.OpenForm "frmYourForm", , , , , , "Customer Y"
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."


tsison7 said:
I have a form where the title can be either "Delivery Reports: Customers X"
or "Delivery Reports: Customers Y".

When a command button is pressed I set a variable "customer" to 1 for
Customers X and to 2 for Customers Y depending on which command button is
pressed.

Since the forms are identical I want to use the same form but have the
title
change depending on which Customers X or Y it is for.

I've set the title to "=iif(customer =1,"Delivery Reports: Customers
X","Delivery Reports: Customers Y))". But all it shows up with is "Name?"

I also had to define "customer" as a Public Variable.

I can get it to work using a function like:

Public Function getmyvariablecustomer() As String
getmyvariabletitle = customer
End Function

and rewriting the statement as =iif(getmyvariablecustomer()=1,.....)

But that seems like the wrong way to go about it....is it?
 

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

Top