Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error with my combo box and using mouse over event 1

Status
Not open for further replies.

Rmck87

Programmer
Jul 14, 2003
182
US
I have a combo box that brings up the projects that were worked on. But, whenever i put this code in to show that the user is hovering over the combo it doesn't let me select the combo drop down arrow. Whenever i select it, the drop down box comes up, but doesnt stay dropped down. Why not? Heres my code:




Private Sub cboProjectID_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Me.cboProjectID.BorderColor = 10485760
Me.cboProjectID.SpecialEffect = 0
End Sub

Private Sub Detail_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Me.cboProjectID.BorderColor = 0
Me.cboProjectID.SpecialEffect = 2
End Sub



This is to sort of highlight the combobox so that the user knows he is over the combo. Just for another cool trick, if i cannot do this that is ok, but it was just something i was trying to do. Any help would be great thanks!

One Ring to Rule Them All, One Ring to Find Them, One Ring to Bring Them All, and in the Darkness Bind Them.
 
I assume that its because your mouse continues to move while over the combobox so that it keeps calling the sub. It doenst look like you use the X and Y values of the mouse position, so as long as it doesnt look at the position, it may just keep calling the event.

if possible, add the formatting to the onclick event or use the X and Y values so that it only calls the sub when the ComboBox is first entered, not while the mouse is continuously over it.
 
Ok, i see what you are saying, but i dont understand how i would make the X and Y values so that it only calls the sub when the combobox is first entered. How would i do this?

One Ring to Rule Them All, One Ring to Find Them, One Ring to Bring Them All, and in the Darkness Bind Them.
 
Ok, sorry, i tried the code without X and Y, and it worked fine.

here is the code i used.

Code:
Private Sub Combo0_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Combo0.BackColor = vbBlue
End Sub

Private Sub Detail_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Combo0.BackColor = vbRed
End Sub

now if you exclude the mousemove events, will the data appear in the combobox? if not, maybe an OnClick event? Let me know.
 
No, that doesnt work. It works if i exclude the mouseover events, so i am assuming that it is what you had said the problem was earlier. That the mouse is constantly moving. I also dont want to change the back color, just the border color, i dont think that that will make a difference. But, i thank you for your help. You said you tried the code without X and Y but when you showed me the code you used, X and Y were still in the first line. Is there a reason for this?

One Ring to Rule Them All, One Ring to Find Them, One Ring to Bring Them All, and in the Darkness Bind Them.
 
When you create the MouseMove Event, the sub is passed the X and Y, your option to use it. I had done the backcolor instead of the bordercolor just for poops and giggles, just as a sample. i had my combo populated with bot values i plugged in and i also linked it to a table. if you say there is data in the combobox when the mousemove event is not called but not there when they are called, then you have me stumped. let me dig up some of my old code where i used the X and Y values to see if it helps.
 
Well, the data i am assuming is there whenever the mouse move event is called. But the thing is that whenever i click the dropdown arrow on the combo, it just blinks down then back up. It wont stay there. I dont know why it is doing this. Any ideas?

One Ring to Rule Them All, One Ring to Find Them, One Ring to Bring Them All, and in the Darkness Bind Them.
 
ok, i know for sure that it is bringing back the correct values, because i can decipher the correct values whenever the combo box drops down, for the split second. But it wont stay down. Any ideas?

One Ring to Rule Them All, One Ring to Find Them, One Ring to Bring Them All, and in the Darkness Bind Them.
 
i only requery the combobox whenever the combobox before it is accessed.. But besides that no. And that requery would have nothing to do with the problem, so, no not really.

One Ring to Rule Them All, One Ring to Find Them, One Ring to Bring Them All, and in the Darkness Bind Them.
 
Post any code associated with the combobox, if its not within the code of the combobox, i would imagine it has to do with code behind the form.
 
Private Sub cboProjectID_AfterUpdate()

If grpSortBy = 1 Then
Me.cboMonth.Requery
ElseIf groupsortby = 3 Then
Me.cboMonth.Requery
End If
End Sub

---This requeries another combobox based on what the selection is in another option group.


Private Sub cboProjectID_GotFocus()

If grpSortBy = 1 Then
cboProjectID.RowSource = " SELECT distinct dbo_pm_project.project_id FROM dbo_pm_project, dbo_time_entry, dbo_time_sheet, dbo_te_period, dbo_member WHERE dbo_te_period.te_period_recid = dbo_time_sheet.te_period_recid and dbo_time_sheet.time_sheet_recid = dbo_time_entry.time_sheet_recid AND dbo_pm_project.pm_project_recid = dbo_time_entry.pm_project_recid and dbo_member.member_recid = dbo_time_entry.member_recid Order By dbo_pm_project.project_id"
ElseIf grpSortBy = 3 Then
Me.cboMonth = Null
cboProjectID.RowSource = " SELECT distinct dbo_pm_project.project_id FROM dbo_pm_project, dbo_time_entry, dbo_time_sheet, dbo_te_period, dbo_member WHERE dbo_te_period.te_period_recid = dbo_time_sheet.te_period_recid and dbo_time_sheet.time_sheet_recid = dbo_time_entry.time_sheet_recid AND dbo_pm_project.pm_project_recid = dbo_time_entry.pm_project_recid and dbo_member.member_recid = dbo_time_entry.member_recid Order By dbo_pm_project.project_id"
End If
End Sub

---This sets the rowsource of the combobox. Based on a selection in the option group mentioned in the last paragraph. All this works fine.


Public Sub cboProjectID_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Me.cboProjectID.BorderColor = 10485760
Me.cboProjectID.SpecialEffect = 0
End Sub


---This sets the border color of the combobox to blue, and the special effect to flat; When the mouse is over the combo. This is where it starts to mess up.


Private Sub Detail_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Me.cboProjectID.BorderColor = 0
Me.cboProjectID.SpecialEffect = 2
End Sub


---This resets the border color back to black, and the special effect back to sunken.


It all seems to work except for the mouseover part of the combobox. The values are correct, it just seems to be doing what you thought it was doing...

'I assume that its because your mouse continues to move while over the combobox so that it keeps calling the sub.'

Thanks for all the help.

One Ring to Rule Them All, One Ring to Find Them, One Ring to Bring Them All, and in the Darkness Bind Them.
 
a couple of ideas:

1) I am curious if it may be the GotFocus sub. Try tabbing into the field and start to type in a known value to see if it will auto-populate the field, if so, try clicking the drop down arrow and see what happens then.

2) comment out all the lines of code in the MouseMove subs and see if the same problem still occurs.

I am sure once we figure it out, we will both kick ourselves.
 
I agree with that phrase. 1) yes it still auto-populates. and no the drop down arrow still blinks back up. 2) i tried commenting out only one line at a time and that didnt work then i commented out all lines and it worked fine. I only had to comment out this paragraph here.

Public Sub cboProjectID_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Me.cboProjectID.BorderColor = 10485760
Me.cboProjectID.SpecialEffect = 0
End Sub

********Weird...

One Ring to Rule Them All, One Ring to Find Them, One Ring to Bring Them All, and in the Darkness Bind Them.
 
hmm, try changing the SpecialEffect to 1, just to see what happens, if it doesnt work, then you got me.
 
No, doesnt work either. Is there any way that i can set the border color only once? instead of everytime the mouse moves over the combo?

One Ring to Rule Them All, One Ring to Find Them, One Ring to Bring Them All, and in the Darkness Bind Them.
 
no, you can change the border using the forms timer to set it every second to something new if you want. I dont have access up right now, but can a border style 0 have a border color property set?
 
Yes, it sure can. I know that border style 2 cannot tho. Whenever the mouse is over the combo, the special effect changes, the color changes and it works fine, its just whenever one clicks on the drop down arrow is when it messes up. I am just going to say that it is because it keeps calling the sub because the mouse is still moving, and whenever you click on the arrow, it drops down, but then calls the sub, and pulls the drop down up again. Do you have Microsoft Outlook?

One Ring to Rule Them All, One Ring to Find Them, One Ring to Bring Them All, and in the Darkness Bind Them.
 
outlook, no, i'm on a gig with the state government here, bunch of anti-microsoft software here...true its faster and more reliable, but the people are just as computer illiterate and the only ones that brag about the network here are the network people, everyone else "dont know jack".

anyway...what if you add a global variable that will tell it to execute code...

Code:
Option Explicit
Private ChangeBorder as Boolean

Private Sub Form_Load()
    ChangeBorder = True
End Sub

Public Sub cboProjectID_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
if ChangeBorder = True then
    Me.cboProjectID.BorderColor = 10485760
    Me.cboProjectID.SpecialEffect = 0
    ChangeBorder = False
end if
End Sub

Private Sub Detail_MouseMove(Button As Integer, Shift As 
Integer, X As Single, Y As Single)
    ChangeBorder = True
    Me.cboProjectID.BorderColor = 0
    Me.cboProjectID.SpecialEffect = 2
End Sub
 
Well, i was just wondering because that is where i got the idea for changing the border color. Just goin to show you what i wanted done. Well, this new code does the same thing. But, it still pulls back up. This is messed up.

One Ring to Rule Them All, One Ring to Find Them, One Ring to Bring Them All, and in the Darkness Bind Them.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top