Set Focus

thart21

Registered User.
Local time
Today, 04:44
Joined
Jun 18, 2002
Messages
236
I am having trouble getting the cursor to change focus after updating a field in my tab control subforms. I have a main form with a tab control and 4 related subforms for each record in the main form.

I have a calendar that pops up with the On Click of my Date field. When the date is selected, it enters it into the field and the calendar closes. For some reason though the user cannot simply go to the next record with the mouse and has to tab to or select another field in the same record first and then click on the Date field in the next record.

I have tried SetFocus to "Hours" (the next field after "Date")and "NextRecord" on every Event I can think of but it does nothing, it just stays on the changed field and the only way to get out of it is to go to another field. I've tried saving, requery, etc. I've also tried the options shown in the forum with no luck and using different events associated with the Calendar form - On Close, Lost Focus, etc.

Any suggestions? Thanks
 
Make sure that your calendar form is transferring the date using the name of the CONTROL and not the name of the recordset field.
 
It is set to the Control "Date", the field name is "DateCompleted".

Thanks for the idea.

Toni
 
How about posting a sample of your db? Is that possible? Generally speaking, people who posted samples along with their questions got their problems solved quicker.
 
In case it helps...
When I use a popup calendar, I do this:
-Double click form date field, popup calendar is opened.
-Select date in cal form, press OK button.
-Code in cal form runs...(don't quote me, this is outa my head)
TempDt = Me.Calendar0.value
DoCmd.Close
Window.ActiveControl = TempDt

...And the form continues to act as normal.

What could you be doing that causes these issues with your form?

btw..."Date" is not a good control name.
 
Here the module that runs the Calendar when the field "Date" is clicked.

'WHAT: OpenCalendar (strSubForm)
Credit goes to: Brock W Denys, Coolhead Incorporated
'WHY : OpenCalendar will open the calendar form and send the subform's name if the subform name is passed to this function.
------------------------------
Function OpenCalendar(ByVal strSubForm As String, Optional strControl As String)

On Error Resume Next

'test to see if anything was sent
If (strSubForm & "" = "") Then
'no subform name sent
If Not IsMissing(strControl) Then
Forms(Screen.ActiveForm.name)(strControl).SetFocus
End If
DoCmd.OpenForm "frmCalendar"
Else
'subform name sent
If Not IsMissing(strControl) Then
Forms(Screen.ActiveForm.name)(strSubForm).SetFocus
Forms(Screen.ActiveForm.name)(strSubForm).Form(strControl).SetFocus
End If
DoCmd.OpenForm "frmCalendar", , , , , , strSubForm
End If

End Function

I had to go with this due to the Tab Control and the other calendars I used would update the same line # on every subform, which I couldn't have. It works great, I just can't figure out why it won't let me use SetFocus to the next field. It wreaking havoc for my users because they are just updating the same record and can't get out of it unless I tell them to tab to the next field first.

Thanks for all of your help
 
Figured this out. I had to go into the "MouseDown" event code in the Calendar form and add this:

DoCmd.GoToControl "Hours"

Works how I want it to now.

Thanks for the help.
 

Users who are viewing this thread

Back
Top Bottom