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

Tab to next field after using the Calendar

Status
Not open for further replies.

nastar1

Technical User
Nov 1, 2005
122
US
After I click on the date I want in the Calendar control, the focus moves to the first data input field on my form.

The form is setup with a Start Date textbox followed by a End Date textbox. Both have a Calendar Control attached and I'd like to have the behavior where the focus goes to the End Date text box after the user clicks a date in the Start Calendar control.

I'm using the following coding:
Private Sub TaskStart_LostFocus()

ocxWAStart.Visible = False

End Sub

Private Sub ocxWAStart_KeyPress(KeyAscii As Integer)

TaskStart.Value = ocxWAStart.Value
ocxWAStart.Visible = False
ocxWAFin.SetFocus

End Sub

I don't understand why the ocxWAFin.SetFocus is not working. I'm overlooking something. Any ideas?
 
I have something similar using Access 97. I have a Calendar Control, two list boxes with time in 1/2 hour increments (lbxStartHour and lbxFinishHour), and text boxes for start and finish (tbxStartReclaiming and tbxFinishReclaiming). When the time is selected from the listbox, the date & time goes into the respective textbox.

I have the following code.

Code:
Private Sub lbxFinishHour_Click()

Me!tbxFinishReclaiming = CVDate(Me!ActiveXCtl93 & " " & Me!lbxFinishHour)

End Sub


Private Sub lbxStartHour_Click()

Me!tbxStartReclaiming = CVDate(Me!ActiveXCtl93 & " " & Me!lbxStartHour)
End Sub

If you have two calendar controls, you could try something like this.

Code:
Private Sub ActiveXCtl93_Click()

Me!TaskStart = Me!ActiveXCtl93

End Sub

Private Sub ActiveXCtl94_Click()

Me!TaskFinish = Me!ActiveXCtl94

End Sub
 
Since you're playing with the visibilty of your first calendar, ocxWAStart, I'm guessing you're doing the same thing with ocxWAFin, and that its visibilty is set to False. You can't set focus to a control unless it's visible! Make it visible then set focus to it!

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
Still no luck. I added the code suggested on the ocxCalendarControl click event and as soon as I click on a date in the ocxCalendarControl it applies the correct date to my textbox, but the focus jumps to the tab#1 field on the form rather than the next tab# which in my case is the next ocxCalendarControl.

I believe I have taken the correct measures to ensure that i've set the control to visible before trying to set focus to it as well.

Any other ideas?
 
I believe I have taken the correct measures to ensure that i've set the control to visible before trying to set focus to it as well."

I take this to mean that you do have its visibilty set to False at some point in time. Exactly where are you setting its visibilty to True? I still think you need to at least try resetting its visibilty just prior to setting its focus:

ocxWAStart.Visible = False
ocxWAFin.Visibility = True
ocxWAFin.SetFocus

I assume you've checked its properties to make sure that you

DO NOT HAVE TabStop set to NO

and

DO NOT HAVE Enabled = No and Lock = Yes

both of which will prevent focus being set.

Linq

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
I'm setting the ocxWAStart.Visible = true in the associated textbox's GotFocus.

I'm also setting the ocxWAFin.Visible = true in its associated textbox's GotFocus.

Both the Calendar control's and associated textbox's Enabled = Yes and Locked = No are set.

The textboxes both have Tab Stop = Yes, numbered 23 and 24 respectively for the Start date and the Finish date.

I did notice that the Calendar Control's also were Enabled = Yes and Locked = No and more interestingly both were set to Tab Stop = Yes, numbered 43 and 44 respectively for the Start calendar and the Finish calendar. I changed both to Tab Stop = No to see if it had any affect and there was none. After I click a date in the ocxWAStart calendar, it updates the associated textbox date, but the focus pops directly to the Tab 1 field rather than Tab Stop 24 which would be the Finish Date textbox which would fire the ocxWAFin.Visible = True.

I don't understand what is overriding the tab stop functionality. If I simply mouse click either of the calendar controls I get the same result. The cursor goes to tab stop 1 rather than the next tab.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top