BackStyle mysteriously changing

C

Christopher Robin

I have a form with 4 combo boxes. 1 combo box is independant of the others,
and works without any problems. The other 3 are a hierarchical control, and
each level's data is dependant upon the selection made from the previous
combo box. This all works fine, but there is one oddity, which I can't
figure out. The 3 combo boxes only have an On Update event to requery the
children. So, the issue is simply that if you click one of these 3 combo
boxes, the combo box will switch from being white to inheriting the form's
color. If you click it again, it will go back to white. There are also no
On Get Focus or On Lost Focus events. I'm totally perplexed and any insight
would be greatly appreciated.

Thanks,
Chris
 
C

Christopher Robin

Marshall Barton said:
That sounds very strange. THe only thoughts I have:

The combo box's BackColor is used when the control gets the
focus, regardless of its BackStyle setting.

Conditional Formatting can affect the control's appearance.

The first click may be selecting all the text in the box,
which is displayed in sort of reverse colors. Then second
click just positions the cursor in the box and colors revert
to the Fore and Back Color settings.
Thank you for the response. It is very strange, which is why I've been
beating my head on my desk lately.

The Fore Color for all 4 combo boxes is #000000 (black) and the Back Color
is #FFFFFF (white). No conditional formatting is set up on any of the combo
boxes.

I also have a check box on the form that updates the values for the 3 combo
boxes (code listed below), and when this occurs, the back color turns back to
white. But again, by clicking inside the combo boxes, the color starts
switching again.

Private Sub SearchBox_Click()
If Me.SearchBox = True Then
Me.NetworkName = 3
Me.NetworkName.Requery
Me.ServiceName = 19
Me.ServiceName.Requery
Me.SiteName = 81
Me.SiteName.Requery
End If
End Sub

Again, thanks for any ideas.

Chris
 
M

Marshall Barton

Christopher said:
Thank you for the response. It is very strange, which is why I've been
beating my head on my desk lately.

The Fore Color for all 4 combo boxes is #000000 (black) and the Back Color
is #FFFFFF (white). No conditional formatting is set up on any of the combo
boxes.

I also have a check box on the form that updates the values for the 3 combo
boxes (code listed below), and when this occurs, the back color turns back to
white. But again, by clicking inside the combo boxes, the color starts
switching again.

Private Sub SearchBox_Click()
If Me.SearchBox = True Then
Me.NetworkName = 3
Me.NetworkName.Requery
Me.ServiceName = 19
Me.ServiceName.Requery
Me.SiteName = 81
Me.SiteName.Requery
End If
End Sub


Beats me. If all else fails try setting some pertinate
events to Debug.Print the BackStyle property, Maybe you'll
stumble over a clue??

OTOH, when logic no longer applies, blame it on corruption
and IMport everything into a new, blank mdb.
 
C

Christopher Robin

Marshall Barton said:
Beats me. If all else fails try setting some pertinate
events to Debug.Print the BackStyle property, Maybe you'll
stumble over a clue??

OTOH, when logic no longer applies, blame it on corruption
and IMport everything into a new, blank mdb.

Well, I guess it's time to import everything into a new db. Here are the
results of my debugging. According to Access, nothing is changing.

NetworkName GotFocus BackStyle: 1
NetworkName GotFocus BackColor: 16777215
NetworkName BackStyle: 1
NetworkName BackColor: 16777215
ServiceName BackStyle: 1
ServiceName BackColor: 16777215
SiteName BackStyle: 1
SiteName BackColor: 16777215
NetworkName BackStyle: 1
NetworkName BackColor: 16777215
ServiceName BackStyle: 1
ServiceName BackColor: 16777215
SiteName BackStyle: 1
SiteName BackColor: 16777215
NetworkName LostFocus BackStyle: 1
NetworkName LostFocus BackColor: 16777215
ServiceName GotFocus BackStyle: 1
ServiceName GotFocus BackColor: 16777215
ServiceName LostFocus BackStyle: 1
ServiceName LostFocus BackColor: 16777215
SiteName GotFocus BackStyle: 1
SiteName GotFocus BackColor: 16777215
SiteName LostFocus BackStyle: 1
SiteName LostFocus BackColor: 16777215
SiteName GotFocus BackStyle: 1
SiteName GotFocus BackColor: 16777215
SiteName LostFocus BackStyle: 1
SiteName LostFocus BackColor: 16777215
ServiceName GotFocus BackStyle: 1
ServiceName GotFocus BackColor: 16777215
ServiceName LostFocus BackStyle: 1
ServiceName LostFocus BackColor: 16777215
NetworkName GotFocus BackStyle: 1
NetworkName GotFocus BackColor: 16777215
NetworkName LostFocus BackStyle: 1
NetworkName LostFocus BackColor: 16777215
ServiceName GotFocus BackStyle: 1
ServiceName GotFocus BackColor: 16777215
ServiceName LostFocus BackStyle: 1
ServiceName LostFocus BackColor: 16777215
SiteName GotFocus BackStyle: 1
SiteName GotFocus BackColor: 16777215
SiteName LostFocus BackStyle: 1
SiteName LostFocus BackColor: 16777215
NetworkName GotFocus BackStyle: 1
NetworkName GotFocus BackColor: 16777215
NetworkName LostFocus BackStyle: 1
NetworkName LostFocus BackColor: 16777215
ServiceName GotFocus BackStyle: 1
ServiceName GotFocus BackColor: 16777215
ServiceName LostFocus BackStyle: 1
ServiceName LostFocus BackColor: 16777215
NetworkName GotFocus BackStyle: 1
NetworkName GotFocus BackColor: 16777215
NetworkName BackStyle: 1
NetworkName BackColor: 16777215
ServiceName BackStyle: 1
ServiceName BackColor: 16777215
SiteName BackStyle: 1
SiteName BackColor: 16777215
NetworkName BackStyle: 1
NetworkName BackColor: 16777215
ServiceName BackStyle: 1
ServiceName BackColor: 16777215
SiteName BackStyle: 1
SiteName BackColor: 16777215
 
M

Marshall Barton

Christopher said:
Well, I guess it's time to import everything into a new db. Here are the
results of my debugging. According to Access, nothing is changing.


Looks like it could well be corruption. If Access says the
properties of interest are always the same, but you are
seeing the effects of changing values, then there is a
serious inconsistency. Make sure you have a backup copy of
the mdb file before trying anything.

I suppose that it could be the form that's corrupted, in
which case you might be able to clean the form by just
making a fresh copy of it using Copy/Paste.

It could also be code corruption where using Decompile is
often sufficient. This page may be helpful:
http://www.granite.ab.ca/access/decompile.htm

OTOH, you may just be seeing the tip of an iceburg where all
kinds of things are out of whack. A full blown attempt to
recover is to first Decompile, Compact and Close. Then
Import everything to a new, blank mdb, Compile, Compact and
Close. If you have a startup form or macro, be sure to hold
sown the Shift key every time you Open, Compact or Decompile
the file so it doesn't try to run any code (which will force
a partial compile) until you reach the point where you
explicitly Compile the entire project.

You should also thoroughly review this page:
http://allenbrowne.com/ser-25.html
 
C

Christopher Robin

Marshall Barton said:
Looks like it could well be corruption. If Access says the
properties of interest are always the same, but you are
seeing the effects of changing values, then there is a
serious inconsistency. Make sure you have a backup copy of
the mdb file before trying anything.

I suppose that it could be the form that's corrupted, in
which case you might be able to clean the form by just
making a fresh copy of it using Copy/Paste.

It could also be code corruption where using Decompile is
often sufficient. This page may be helpful:
http://www.granite.ab.ca/access/decompile.htm

OTOH, you may just be seeing the tip of an iceburg where all
kinds of things are out of whack. A full blown attempt to
recover is to first Decompile, Compact and Close. Then
Import everything to a new, blank mdb, Compile, Compact and
Close. If you have a startup form or macro, be sure to hold
sown the Shift key every time you Open, Compact or Decompile
the file so it doesn't try to run any code (which will force
a partial compile) until you reach the point where you
explicitly Compile the entire project.

You should also thoroughly review this page:
http://allenbrowne.com/ser-25.html
Interestingly enough, I located this KB article,
http://support.microsoft.com/kb/208344, which is the exact opposite of what
I'm experiencing. I've yet to find something describing my issue as well as
this article. I've tried all of your suggestions to no avail. I guess I'm
limited to using a white form, until I find the corresponding KB article.

Thanks,
Chris
 
M

Marshall Barton

Christopher said:
Interestingly enough, I located this KB article,
http://support.microsoft.com/kb/208344, which is the exact opposite of what
I'm experiencing. I've yet to find something describing my issue as well as
this article. I've tried all of your suggestions to no avail. I guess I'm
limited to using a white form, until I find the corresponding KB article.


Yeah, I mentioned the effect in that KB earlier and that it
is normal behavior.

I wonder if your effect is really transparent. Try placing
a colored rectangle partially behind the text box. Then
check if the rectanhle shows through after you click in the
text box.
 
C

Christopher Robin

Marshall Barton said:
Yeah, I mentioned the effect in that KB earlier and that it
is normal behavior.

I wonder if your effect is really transparent. Try placing
a colored rectangle partially behind the text box. Then
check if the rectanhle shows through after you click in the
text box.
OMG!! So I placed a colored rectangle behind the 3 linked combo boxes, and
I no longer see the odd behavior. The stand alone combo box, however,
inherits the strange effect. So, I extended my rectangle to sit behind all 4
combo boxes, set it's color to the same as my form, and the borders as
transparent, and now the combo boxes are behaving as I would expect.

I hope they don't consider this behavior normal or expected. This has got
to be the oddes thing I've encountered yet.

Thanks for your help,
Chris
 
M

Marshall Barton

Christopher said:
OMG!! So I placed a colored rectangle behind the 3 linked combo boxes, and
I no longer see the odd behavior. The stand alone combo box, however,
inherits the strange effect. So, I extended my rectangle to sit behind all 4
combo boxes, set it's color to the same as my form, and the borders as
transparent, and now the combo boxes are behaving as I would expect.

I hope they don't consider this behavior normal or expected. This has got
to be the oddes thing I've encountered yet.


This is just too bizzare. IMO, that is not a workaround as
much as it masks the problem.

Did you use Format - Send to Back to place the rectangle
behind everything or is it possible that it's in front of
some other rectangle, label, or ??
 
C

Christopher Robin

Marshall Barton said:
This is just too bizzare. IMO, that is not a workaround as
much as it masks the problem.

Did you use Format - Send to Back to place the rectangle
behind everything or is it possible that it's in front of
some other rectangle, label, or ??

I would agree that this is very bizarre. I sent the rectangle to the back.
The original test involved a beautiful shade of purple on a white form, and
this rectangle was also sent to the back. There are a total of 10 controls
on this form. 4 combo boxes, 3 text boxes, 1 check box and 2 command
buttons. The new colored rectangle makes 11. The header also contains 2
objects: an image and a text box. Everything listed in the Property Sheet is
visible and accounted for on the form.
 
M

Marshall Barton

Christopher said:
I would agree that this is very bizarre. I sent the rectangle to the back.
The original test involved a beautiful shade of purple on a white form, and
this rectangle was also sent to the back. There are a total of 10 controls
on this form. 4 combo boxes, 3 text boxes, 1 check box and 2 command
buttons. The new colored rectangle makes 11. The header also contains 2
objects: an image and a text box. Everything listed in the Property Sheet is
visible and accounted for on the form.


I really don't get it. Corruption of some kind is my only
reasonable explanation. I recommend that you follow
rigorous backup procedures in case things get worse.

As far as trying to clear it. If you haven't already done
it, try deleting the offending text box and then recreating
from scratch.

I've never had to do this, but others report that when all
else fails, the usually(?) successful technique is to use
the (semi) undocumented SaveAsText/LoadFromText
methods. Use the Immediate/Debug window:

Application.SaveAsText acForm, "form name", "a temp file"

Next rename the form in the database window.

Then, back in the debug window, use:

Application.LoadFromText acForm, "form name", "a temp file"
 
Top