By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,984 Members | 1,009 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,984 IT Pros & Developers. It's quick & easy.

Buttons still appear "highlighted" after being clicked

P: 12
I have a form which contains some buttons. The buttons use some of the standard images that come with access 2003 (e.g., the move next record image, or the sort ascending/descending images). The default behavior for access is to give the button a "highlighted" appearance when the button is hovered with the mouse.

My problem is that these buttons permanently have that "highlighted" appearance after they have been clicked. With my XP theme, that happens to be an orange border.

Oddly enough, I can get the buttons to go back to their normal appearance if I have another control slightly overlapping them. This works in most cases, but is not a satisfactory solution.

All the buttons are in my form header. I don't think I'm doing anything in code to cause this to happen, but just in case, I've included code for one of the buttons below.

Has anyone run across this before? Does anyone know how to ensure the buttons go back to their "normal" appearance after they have been clicked?

Expand|Select|Wrap|Line Numbers
  1.  
  2. 'Button to set the recordset of the form to the records associated with the
  3. 'last computer ID in my array (the array contains the computer IDs for 
  4. 'all the computers that matched search criteria specified by the user).
  5. 'Other buttons are similar-- they go to the first
  6. 'computer ID in the array, or increment or decrement current array index..
  7.  
  8. Private Sub lastComputer_Click()
  9. On Error GoTo Err_lastComputer_Click
  10.  
  11.     searchComputerIDArrayCurrent = UBound(searchComputerIDArray)
  12.     displayCurrentSearchResults
  13.  
  14.     'DoCmd.GoToRecord , , acLast
  15.  
  16. Exit_lastComputer_Click:
  17.     Exit Sub
  18.  
  19. Err_lastComputer_Click:
  20.     MsgBox Err.Description
  21.     Resume Exit_lastComputer_Click
  22.  
  23. End Sub
  24.  
  25. Public Sub displayCurrentSearchResults()
  26.  
  27.     'display the correct values in the combo boxes, even though they aren't enabled
  28.     computerComboBox = searchComputerIDArray(searchComputerIDArrayCurrent)
  29.     Me.subsystemComboBox.Value = Me.computerComboBox.Column(5)
  30.     Me.siteComboBox.Value = Me.computerComboBox.Column(4)
  31.  
  32.     'display the current record number in the navigation bar
  33.     Me.currentComputerTextBox = searchComputerIDArrayCurrent + 1
  34.  
  35.     'make sure the appropriate navigation buttons are enabled/disabled
  36.     Me.prevComputer.Enabled = True
  37.     Me.nextComputer.Enabled = True
  38.  
  39.     If (searchComputerIDArrayCurrent = LBound(searchComputerIDArray)) Then
  40.         Me.currentComputerTextBox.SetFocus
  41.         Me.prevComputer.Enabled = False
  42.     End If
  43.  
  44.     If (searchComputerIDArrayCurrent = UBound(searchComputerIDArray)) Then
  45.         Me.currentComputerTextBox.SetFocus
  46.         Me.nextComputer.Enabled = False
  47.     End If
  48.  
  49.     'requery the form
  50.     Me.Requery
  51.  
  52. End Sub
  53.  
Mar 20 '07 #1
Share this Question
Share on Google+
11 Replies


MMcCarthy
Expert Mod 10K+
P: 14,534
Not sure why this is happening. Try adding and Me.Refresh at the end of the button click event code.

Mary
Mar 21 '07 #2

P: 12
Mary,

Thanks for responding. No luck with the Me.Refresh, unfortunately. Any other ideas?

Even setting the Visible property to False and then back to True doesn't reset the way they're displayed, they still show that "highlight" permanently after they've been clicked. I also tried Me.Repaint, and that did not work either.

Thanks,
Dana
Mar 21 '07 #3

P: 12
One thing that does appear to work is to disable/enable the button. Again, this isn't really a good solution...

But I guess it will work if we can't figure out why the behaviour is happening in the first place.

Expand|Select|Wrap|Line Numbers
  1. Private Sub lastComputer_Click()
  2. On Error GoTo Err_lastComputer_Click
  3.  
  4.     searchComputerIDArrayCurrent = UBound(searchComputerIDArray)
  5.     displayCurrentSearchResults
  6.     Me.currentComputerTextBox.SetFocus
  7.     Me.lastComputer.Enabled = False
  8.     Me.lastComputer.Enabled = True
  9.     Me.lastComputer.SetFocus
  10.  
  11.     'DoCmd.GoToRecord , , acLast
  12.  
  13. Exit_lastComputer_Click:
  14.     Exit Sub
  15.  
  16. Err_lastComputer_Click:
  17.     MsgBox Err.Description
  18.     Resume Exit_lastComputer_Click
  19.  
  20. End Sub
  21.  
Mar 21 '07 #4

P: 12
....Actually... like the overlapping thing, this only works for some buttons. And, it ends up leaving a green "highlight" instead of an orange "highlight" (probably XP theme colors for something) on the buttons I use it on. The green highlight isn't permanent, but it displays or doesn't display depending on whether the button next to it is enabled/disabled (or so it appears).


[quote=dana1]One thing that does appear to work is to disable/enable the button. Again, this isn't really a good solution...
Mar 21 '07 #5

Denburt
Expert 100+
P: 1,356
May or may not be but are you sure you are using a command button and not a Toggle Button? I don't have my XP themes turned on my Machine is as plain looking as they come so I might not see what you are seeing but the only time my command button highlights is when I click on it and it always snaps back.

Return a Toggle Button:
Me!YourControlNameHere.Value = 1
Mar 21 '07 #6

P: 12
Denburt,

Good thought-- I hadn't thought to check that. Unfortunately, it does not appear that they are toggle buttons. I don't see how to tell the type of the control from the GUI, but the ControlType property returns 104, which is a command button. Also, the Value property isn't available from VB, so it appears that is not what is going on.

It's not really the "snapping back" part that is the problem. It does that just fine. It's just the orange border... It's the same orange border that I get when I hover any other button on any of my other forms, or even the buttons on this website (i.e., the Submit Reply or Preview Post buttons). The only difference is on this particular form, the orange border doesn't go away once you've clicked the button :-)

I've compared all the property settings on this button to other buttons that work just fine, and cannot figure out what the difference is..

Thanks for the suggestion! If you have any other ideas, let me know!

or.. if there's any more information that might help you be able to reproduce the behaviour on your machine, let me know and I'd be glad to provide it.

Dana


May or may not be but are you sure you are using a command button and not a Toggle Button? I don't have my XP themes turned on my Machine is as plain looking as they come so I might not see what you are seeing but the only time my command button highlights is when I click on it and it always snaps back.

Return a Toggle Button:
Me!YourControlNameHere.Value = 1
Mar 21 '07 #7

Denburt
Expert 100+
P: 1,356
OK I set winXP themes and checked it out I wasn't able to reproduce your issue but I see how the highlighting is done now... Interesting situation you are describing and I can only suggest deleting that button and creating a new one. I have had some issues with widows themes acting screwy with my buttons before. I had one user download the frontend off the server and the buttons were the old style, user two downloaded the same database and the buttons had the themes style... I told them it was something they would just need to get used to lol. A few days later new update on the server (only a few minor code changes) both users had the themed style buttons go figure.

Wish I could offer something else to try, good luck.
Mar 21 '07 #8

P: 12
Thanks Denburt. I'll try creating new buttons next week and let you know how that works out.

Dana
Mar 23 '07 #9

Denburt
Expert 100+
P: 1,356
Your welcome, and good luck let us know how it goes.
Mar 23 '07 #10

P: 12
Here's the verdict:

Creating brand new buttons from the wizard and making no modifications to them do the same thing, so maybe what I'm seeing is some undocumented "feature" of Access. (Maybe because the buttons are in the Header of the form the focus on them is different? I've done similar things with buttons in the footer and had no problems)

The best solution for the navigation buttons seems to be to move focus away from the button, disable the button, enable the button, then move focus back to the button. The unfortunate side effect of moving focus to the button programatically like this is that the button temporarily gets a green highlight. This goes away when the user moves focus to somewhere else using the mouse. Unfortunately, moving focus elsewhere via VBA doesn't do the trick.

For my sort ascending and sort descending buttons, having another control slightly overlap the buttons seems to do the trick. These buttons are always enabled, so overlapping works. I sometimes disable some of the navigation buttons (i.e., the "Next" button is disabled when I'm on the last record), and that messes up the "overlap" solution.

These aren't really what I would call "Ideal" solutions-- but if no one else can repeat what I'm seeing, there may not be an "Ideal" solution!

Thanks to the two of you who provided input!

Dana
Apr 3 '07 #11

Denburt
Expert 100+
P: 1,356
Thanks for the update. I tried it again setting up buttons in the header (turned WinXP themes back on) and was unable to reproduce the results. I know that there are a number of anomalies similar to this that I have run into over the years so it doesn't surprise me. Glad you were able to find a workaround.
Apr 4 '07 #12

Post your reply

Sign in to post your reply or Sign up for a free account.