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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MonthView Control 1

Status
Not open for further replies.

barrytraver

Programmer
Nov 28, 2000
40
0
0
US
I'm using a MonthView control to let the user choose a date.

I put the MonthView control (plus a label and an OK command) button on a dialog box form which I call modally. The label simply says, "Choose a date and click on OK."

Here's the problem. For some reason (and I can't figure out why), it takes not one click but two to trigger the cmdOK_Click event!

Private Sub cmdOK_Click()
Debug.Print "The OK button was clicked."
frmChooseDateDialog.Hide
End Sub

Once that event is triggered, I can use the value in the calling form like this:

Date1 = frmChooseDateDialog.MonthView1.Value

The only problem, as I said, is that it takes two clicks (not one) to fire the cmdOK_Click event.

Does anyone have any idea what's going on (and, more important, how I can fix it so that a single click will trigger the cmdOK_Click event)?

Additional information: If the user clicks immediately on the OK button, a single click is sufficient to trigger the event (but that defeats the purpose, of course, which is to let the user select a date). Once the user clicks on the MonthVIew control, however, it takes a double click to trigger the cmdOK_Click event.

Thanks in advance for any assistance you might be able to provide.
 
Hi Barrytraver!
I also have experienced the same problem without being able to resolve it. It seems to me that the Monthview control likes to hog focus. I have decided to live with this. If you do get an answer, please let me know - Micash.
 
Yes, the MonthView is indeed a focus hog. However, you can overcome this by using the following:

Private Sub cmdOK_Click()
Debug.Print "The OK button was clicked."
frmChooseDateDialog.Hide
End Sub

Private Sub cmdOK_MouseMove(Button as Integer, Shift as Integer, X as Single, Y as Single,)
cmdOK.SetFocus
End Sub

This way, when you move your mouse over the OK button, it automatically receives focus, no matter how hungry the MonthView is *smile* :p. And after that all it takes is one click.

Let me know how this works for you. Best Regards and many Thanks!
Michael G. Bronner X-)

"Open your mind, and the rest will follow."
 
Not sure about the month view control, but a similar situation can occur if the control is the FIRST control in the Tab order?


MichaelRed
redmsp@erols.com

There is never time to do it right but there is always time to do it over
 
I have experienced a similar situation with with custom controls inside a datarepeater: to access a textbox or any other control within the custom control, i must first click on the repeated control i wish to select, then i must click again the the control within the custom control to select that control.

Is that normal, or is that due to a bug?

(I solved that problem using the same principle I posted above) Best Regards and many Thanks!
Michael G. Bronner X-)

"Beer is proof that God wants us to be happy." Ben Franklin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top