Backcolor Subform control

  • Thread starter Thread starter shiro
  • Start date Start date
S

shiro

I tried to change my subform textbox backcolor to red on
AfterUpdate even but wasn't success.I want VBA code check
the subform textbox value,is it over or lower than the value
in a textbox in my mainform with IF statement but unsuccessful,
please help how to make it works.Thank's
 
Hi Shiro,

Does your version of Access have conditional formatting?
If it does, use conditional formatting to change the textbox color when
certain conditions are met.

Jeanette Cunningham
 
Dear Ms Jeanette,
My Access is Access 2000 and does have condition formatting?
But the problem, I can't refer to the control in my subform.
I have searched in microsoft knowledge base,and found 'how to
refer to control on subform' but It make no sense.Maybe I was
wrong on how to write the identifier.Please help,how you do it
to make it works?Thank's for reply.
 
If you are in the mainform when you want to set the conditional formatting
use:
me.[subformname].form.[controlname]

an example for a subform called subform1 with a textbox called txt1

(to see what your subform is called:
in design view of the main form, click only once on the subform,
now look on the form's property sheet, under the tab called other, next to
Name will be the name of the subform.
Note: this is not the same as the name of the form on the Data tab)

the syntax is:
me.subform1.form.txt1

when you code it you need to replace subform1 with the name of your subform
and txt1 with the name of your control

Jeanette Cunningham
 
when you are on the main form use:

me.[name of your subform].form.[name of your control]

example with a subform called subform1 and a textbox called txt1

me.subform1.form.txt1

Relace subform1 with the name of your subform and txt1 with the name of your
control on your subform.

To find the name of your subform
Open your main form in design view, click once only on the subform so you
can see the black handles around it.
On the form's property sheet go to the tab called other,
on the right next to Name . . . . you will see the name of your subform.
Note: the name of the form on the data tab is not the name of your subform -
it is the name of the form that is inside your subform.

Jeanette Cunningham
 
Thank's Ms Jeanette,
but I got it works like this

[Forms]![Main Form Name].[Form]![Main Form Control Name]

I write it in the conditional formating of my subform control.
Thank's for your help.

Jeanette Cunningham said:
when you are on the main form use:

me.[name of your subform].form.[name of your control]

example with a subform called subform1 and a textbox called txt1

me.subform1.form.txt1

Relace subform1 with the name of your subform and txt1 with the name of your
control on your subform.

To find the name of your subform
Open your main form in design view, click once only on the subform so you
can see the black handles around it.
On the form's property sheet go to the tab called other,
on the right next to Name . . . . you will see the name of your subform.
Note: the name of the form on the data tab is not the name of your subform -
it is the name of the form that is inside your subform.

Jeanette Cunningham





shiro said:
Dear Ms Jeanette,
My Access is Access 2000 and does have condition formatting?
But the problem, I can't refer to the control in my subform.
I have searched in microsoft knowledge base,and found 'how to
refer to control on subform' but It make no sense.Maybe I was
wrong on how to write the identifier.Please help,how you do it
to make it works?Thank's for reply.
 
Just a bit of clarification.

The syntax is not

me.[name of your subform].form.[name of your control]

It's

me.[name of subform control on main form].form.[name of control on subform]

It's not uncommon for the name of the control that holds the subform to be
different than the name of the form being used as a subform.


--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Jeanette Cunningham said:
when you are on the main form use:

me.[name of your subform].form.[name of your control]

example with a subform called subform1 and a textbox called txt1

me.subform1.form.txt1

Relace subform1 with the name of your subform and txt1 with the name of
your control on your subform.

To find the name of your subform
Open your main form in design view, click once only on the subform so you
can see the black handles around it.
On the form's property sheet go to the tab called other,
on the right next to Name . . . . you will see the name of your subform.
Note: the name of the form on the data tab is not the name of your
subform -
it is the name of the form that is inside your subform.

Jeanette Cunningham





shiro said:
Dear Ms Jeanette,
My Access is Access 2000 and does have condition formatting?
But the problem, I can't refer to the control in my subform.
I have searched in microsoft knowledge base,and found 'how to
refer to control on subform' but It make no sense.Maybe I was
wrong on how to write the identifier.Please help,how you do it
to make it works?Thank's for reply.
 
I'm sorry,I'm back with one more question.
I'm trying to code the conditional formatting,but not get excatly what I
want.
In my continuous form,conditional formating formatted one record and
one textbox of the field which met condition.But with below code on the
after
update even of my subform control,it formates 'all textbox' of my field.How
is
the right way to code conditional formatting.?

If [Forms]![Data input_frm].[Form]![re_curr1].Value = "Max" And
Current_1.Value > [Forms]![Data input_frm].[Form]![current1lolimit].Value
Then
Current_1.BackColor = 255
Current_1.ForeColor = 65535
End If



Douglas J. Steele said:
Just a bit of clarification.

The syntax is not

me.[name of your subform].form.[name of your control]

It's

me.[name of subform control on main form].form.[name of control on subform]

It's not uncommon for the name of the control that holds the subform to be
different than the name of the form being used as a subform.


--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Jeanette Cunningham said:
when you are on the main form use:

me.[name of your subform].form.[name of your control]

example with a subform called subform1 and a textbox called txt1

me.subform1.form.txt1

Relace subform1 with the name of your subform and txt1 with the name of
your control on your subform.

To find the name of your subform
Open your main form in design view, click once only on the subform so you
can see the black handles around it.
On the form's property sheet go to the tab called other,
on the right next to Name . . . . you will see the name of your subform.
Note: the name of the form on the data tab is not the name of your
subform -
it is the name of the form that is inside your subform.

Jeanette Cunningham





shiro said:
Dear Ms Jeanette,
My Access is Access 2000 and does have condition formatting?
But the problem, I can't refer to the control in my subform.
I have searched in microsoft knowledge base,and found 'how to
refer to control on subform' but It make no sense.Maybe I was
wrong on how to write the identifier.Please help,how you do it
to make it works?Thank's for reply.


Hi Shiro,

Does your version of Access have conditional formatting?
If it does, use conditional formatting to change the textbox color when
certain conditions are met.

Jeanette Cunningham
I tried to change my subform textbox backcolor to red on
AfterUpdate even but wasn't success.I want VBA code check
the subform textbox value,is it over or lower than the value
in a textbox in my mainform with IF statement but unsuccessful,
please help how to make it works.Thank's
 
Conditional formatting doesn't involve writing code like that. You choose
"Conditional Formatting" from the Format menu when the form's open in Design
view.

Sorry, but I can't remember whether Access 2000 had Conditional Formatting
in it: I actually never worked with that version.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


shiro said:
I'm sorry,I'm back with one more question.
I'm trying to code the conditional formatting,but not get excatly what I
want.
In my continuous form,conditional formating formatted one record and
one textbox of the field which met condition.But with below code on the
after
update even of my subform control,it formates 'all textbox' of my
field.How
is
the right way to code conditional formatting.?

If [Forms]![Data input_frm].[Form]![re_curr1].Value = "Max" And
Current_1.Value > [Forms]![Data input_frm].[Form]![current1lolimit].Value
Then
Current_1.BackColor = 255
Current_1.ForeColor = 65535
End If



Douglas J. Steele said:
Just a bit of clarification.

The syntax is not

me.[name of your subform].form.[name of your control]

It's

me.[name of subform control on main form].form.[name of control on subform]

It's not uncommon for the name of the control that holds the subform to
be
different than the name of the form being used as a subform.


--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Jeanette Cunningham said:
when you are on the main form use:

me.[name of your subform].form.[name of your control]

example with a subform called subform1 and a textbox called txt1

me.subform1.form.txt1

Relace subform1 with the name of your subform and txt1 with the name of
your control on your subform.

To find the name of your subform
Open your main form in design view, click once only on the subform so you
can see the black handles around it.
On the form's property sheet go to the tab called other,
on the right next to Name . . . . you will see the name of your subform.
Note: the name of the form on the data tab is not the name of your
subform -
it is the name of the form that is inside your subform.

Jeanette Cunningham





Dear Ms Jeanette,
My Access is Access 2000 and does have condition formatting?
But the problem, I can't refer to the control in my subform.
I have searched in microsoft knowledge base,and found 'how to
refer to control on subform' but It make no sense.Maybe I was
wrong on how to write the identifier.Please help,how you do it
to make it works?Thank's for reply.


Hi Shiro,

Does your version of Access have conditional formatting?
If it does, use conditional formatting to change the textbox color when
certain conditions are met.

Jeanette Cunningham
I tried to change my subform textbox backcolor to red on
AfterUpdate even but wasn't success.I want VBA code check
the subform textbox value,is it over or lower than the value
in a textbox in my mainform with IF statement but unsuccessful,
please help how to make it works.Thank's
 
Shiro, to do conditional formatting, choose Format from the toolbar/menu
when in form design view, from the menu that drops down choose conditional
formatting. Fill in the form that appears with the conditions and properties
you want for conditional formatting.

Jeanette Cunningham


Douglas J. Steele said:
Conditional formatting doesn't involve writing code like that. You choose
"Conditional Formatting" from the Format menu when the form's open in
Design view.

Sorry, but I can't remember whether Access 2000 had Conditional Formatting
in it: I actually never worked with that version.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


shiro said:
I'm sorry,I'm back with one more question.
I'm trying to code the conditional formatting,but not get excatly what I
want.
In my continuous form,conditional formating formatted one record and
one textbox of the field which met condition.But with below code on the
after
update even of my subform control,it formates 'all textbox' of my
field.How
is
the right way to code conditional formatting.?

If [Forms]![Data input_frm].[Form]![re_curr1].Value = "Max" And
Current_1.Value > [Forms]![Data input_frm].[Form]![current1lolimit].Value
Then
Current_1.BackColor = 255
Current_1.ForeColor = 65535
End If



Douglas J. Steele said:
Just a bit of clarification.

The syntax is not

me.[name of your subform].form.[name of your control]

It's

me.[name of subform control on main form].form.[name of control on subform]

It's not uncommon for the name of the control that holds the subform to
be
different than the name of the form being used as a subform.


--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


when you are on the main form use:

me.[name of your subform].form.[name of your control]

example with a subform called subform1 and a textbox called txt1

me.subform1.form.txt1

Relace subform1 with the name of your subform and txt1 with the name
of
your control on your subform.

To find the name of your subform
Open your main form in design view, click once only on the subform so you
can see the black handles around it.
On the form's property sheet go to the tab called other,
on the right next to Name . . . . you will see the name of your subform.
Note: the name of the form on the data tab is not the name of your
subform -
it is the name of the form that is inside your subform.

Jeanette Cunningham





Dear Ms Jeanette,
My Access is Access 2000 and does have condition formatting?
But the problem, I can't refer to the control in my subform.
I have searched in microsoft knowledge base,and found 'how to
refer to control on subform' but It make no sense.Maybe I was
wrong on how to write the identifier.Please help,how you do it
to make it works?Thank's for reply.


message
Hi Shiro,

Does your version of Access have conditional formatting?
If it does, use conditional formatting to change the textbox color when
certain conditions are met.

Jeanette Cunningham
I tried to change my subform textbox backcolor to red on
AfterUpdate even but wasn't success.I want VBA code check
the subform textbox value,is it over or lower than the value
in a textbox in my mainform with IF statement but unsuccessful,
please help how to make it works.Thank's
 
Back
Top