RE: Make Backstyle transparent on continuous form

Tech-Archive recommends: Speed Up your PC by fixing your registry



I have tested this and it works for me.

Is [Chk] the name of your checkbox - this is what you have:
"ToggleControl([Chk])")
You have formerly called this [ChkBox]

If you still can't get it working, post a temp email address and I will
email you. It would probably be easier if I just do it for you...

Steve

"RFrechette" wrote:

Hi Steve,

After I made the changes you suggested, when I check off the [ChkBox], all
the fields on the form flash gray for a second then back to white. But the
record where the box is checked is still white as well.

These are the changes I made:

For all the textboxes, I changed Enabled to True. And changed .Enabled =
False in the code. (See below)

Private Sub Form_Load()

Dim objFcnd As FormatCondition
Dim ctl As Control

For Each ctl In Me.Controls
If TypeOf ctl Is TextBox Then

'Delete conditions for current control
ctl.FormatConditions.Delete

Set objFcnd = ctl.FormatConditions.Add(acExpression, ,
"ToggleControl([Chk])")

' Set property
With objFcnd
.Enabled = False
End With

End If
Next

Set objFcnd = Nothing

End Sub

Any thoughts?

Thank you so much. I'm sorry this is such a pain in the neck.
Rachel

"SteveM" wrote:

Ok you are doing this the opposite to what I have done. In my system, records
are ticked when they are 'active' so this is the opposite of what you want.
We just need to change a couple of things.

Set all your textbox properties to Enabled = Yes
Then change .Enabled = True to .Enabled = False in the Onload event
procedure.:

Steve

"RFrechette" wrote:

Hi Steve,

Again, thank you for everything. When I use the form now, all the textboxes
are not enabled so they are all grayed out. When I check the [ChkBox] field,
it appears that nothing happens. The only difference is that the row has a
checkmark in the [ChkBox] field. I was hoping for any field without a
checkmark in [ChkBox] will be white, once I put a checkmark on that record,
it turns gray.

I understand if you're too busy to continue helping me and you may not want
to spend any more time on this. However, if you wish to continue, here's
what I got...

All textboxes’ .Enabled property is set to 'No'

I have the following code in a standard module:

Public Function ToggleControl(ctl As Control) As Boolean

ToggleControl = ctl.Value

'Steve, when I typed ToggleControl = ctl. above, "Value" does not
show up as one of the options
' to choose from, but I typed it anyway

End Function

In the Form's OnLoad event, I have the following code:

Private Sub Form_Load()

Dim objFcnd As FormatCondition
Dim ctl As Control

For Each ctl In Me.Controls
If TypeOf ctl Is TextBox Then

'Delete conditions for current control
ctl.FormatConditions.Delete

Set objFcnd = ctl.FormatConditions.Add(acExpression, ,
"ToggleControl([ChkBox])")

' Set property
With objFcnd
.Enabled = True
End With

End If
Next

Set objFcnd = Nothing

End Sub

Thank you for everything.

Rachel

"SteveM" wrote:

It goes to the Sub Function that I put in the OnLoad event and stops at
".ctl" in the following line:
Me.ctl.FormatConditions.Delete

Sorry, remove the 'Me.' to ctl.FormatConditions.Delete
Also remove 'Me.' to ctl.FormatConditions.Add(acExpression, ,
"ToggleControl([myYesNoField])")

Should start; Public Function ToggleControl(ctl As Control) As Boolean

Sorry about that. I actually copied the code from an in-progress backup and
I obviously hadn't finished with this at the time!

Steve

I did type the Public Function in myself and as I was typing, when I got to
the line:
ToggleControl = ctl.Value
the "value" part was not in the dropdown list that automatically pops up
after you type the ctl.

What did I do wrong? Any thoughts?

Again, thank you so much for your help.

Rachel


"SteveM" wrote:

Ah! you have reminded me of something...
A while back I had the task of displaying 'inactive' records like you seem
to desire but in fact I found a way to disable all textboxes in those records
which added a couple of other advantages. I just found the backup and checked
the code I used - it is quite simple and I should have put this in my code
library DB!

First of all you can remove the extrat textboxes that we were using in the
previous posts.

Set all your textbox .Enabled property to 'No'

Put the following code in a standard module:
Public Function ToggleControl(ctl As Control)

ToggleControl = ctl.Value

End Function

Now in your Form's OnLoad event, put the following code:
Private Sub Form_Load()

Dim objFcnd As FormatCondition
Dim ctl As Control

For Each ctl in Me.Controls
If TypeOf ctl Is Textbox Then

' Delete conditions for current control
Me.ctl.FormatConditions.Delete

Set objFcnd = Me.ctl.FormatConditions.Add(acExpression, ,
"ToggleControl([myYesNoField])")

' Set property
With objFcnd
.Enabled = True
End With

End If
Next

Set objFcnd = Nothing

End Sub

That's it! Try it out, it may actually be closer to what you are looking
for...
Change 'myYesNoField' to the name of your checkbox.

Steve

"RFrechette" wrote:

It turns out that the reason the cell is white when I FIRST open the form is
because it is the active cell. After the form is open, when the "txt_AcctNo"
cell is selected on any record, the BackColor turns white.

"RFrechette" wrote:

Steve,

Thank you for your rapid responses. I think I followed your directions
correctly, please see below.

“txt_AcctNo” is my original textbox.
“txt_AcctNo1” is placed underneath “txt_AcctNo”.

BackStyle of “txt_AcctNo” and “txt_AcctNo1” are both set to:
Transparent.

ControlSource of “txt_AcctNo1” is set to:
=IIf(mycheckbox = True, "", True)

ControlSource of “txt_AcctNo” is set to:
AcctNo (field from the underlying table)

ForeColor of “txt_AcctNo1” is set to:
–2147483633
(This is the BackColor of the Detail Section)

FontName of “txt_AcctNo1” is set to:
System

FontSize of “txt_AcctNo1” is set to:
1

Format of “txt_AcctNo1” is set to:
;"ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ"

My Results:

When I open the form:
BackColor of “txt_AcctNo” is White (Whether “mycheckbox” is true or not)
(This should only be White if “mycheckbox” is false. If “mycheckbox” is
true, it should be the same color as the detail BackColor.)

If “mycheckbox” is not checked and I check it:
BackColor of “txt_AcctNo” is the same color as the BackColor of the detail
section
(This is what I want it to be if “mycheckbox” is true)

If “mycheckbox” is checked and I uncheck it:
BackColor of “txt_AcctNo” is the same color as the BackColor of the detail
section
(The BackColor of “txt_AcctNo” should be White if “mycheckbox” is false)

It looks like I’m getting a lot closer.

Any other suggestions?

Thank you,
Rachel


"SteveM" wrote:

I set the ControlSource for txt_AcctNo to: IIf(mycheckbox = True, "", True)
Needs to be: =IIf(mycheckbox = True, "", True) '(with the = sign)
Should be txt_AcctNo1

I set the ForeColor of txt_AcctNo to White
Should be txt_AcctNo1

Steve
.



Relevant Pages

  • RE: Make Backstyle transparent on continuous form
    ... Public Function ToggleControl(ctl As Control) As Boolean ... For Each ctl In Me.Controls ... If TypeOf ctl Is TextBox Then ... cell is selected on any record, the BackColor turns white. ...
    (microsoft.public.access.formscoding)
  • RE: Make Backstyle transparent on continuous form
    ... Dim objFcnd As FormatCondition ... For Each ctl In Me.Controls ... If TypeOf ctl Is TextBox Then ... 'Delete conditions for current control ...
    (microsoft.public.access.formscoding)
  • RE: Make Backstyle transparent on continuous form
    ... Dim objFcnd As FormatCondition ... For Each ctl In Me.Controls ... If TypeOf ctl Is TextBox Then ... 'Delete conditions for current control ...
    (microsoft.public.access.formscoding)
  • RE: Make Backstyle transparent on continuous form
    ... Dim objFcnd As FormatCondition ... For Each ctl In Me.Controls ... If TypeOf ctl Is TextBox Then ... 'Delete conditions for current control ...
    (microsoft.public.access.formscoding)
  • RE: Make Backstyle transparent on continuous form
    ... Dim objFcnd As FormatCondition ... For Each ctl in Me.Controls ... If TypeOf ctl Is Textbox Then ... cell is selected on any record, the BackColor turns white. ...
    (microsoft.public.access.formscoding)