Setfocus on continuous suform (also posted on accessvba.com)

MLT

Registered User.
Local time
Today, 06:12
Joined
Nov 14, 2002
Messages
12
Setfocus on continuous subform (also posted on accessvba.com)

I have a time card app with a subform set to continuous forms (see image).

I want the tab key to navigate easily through the subform but it doesn't. I use the recalc function in the change and after_update events on the text boxes for regular and overtime hours. The function makes the cursor action unpredictable. When it runs, the cursor jumps back to the account field and to the 1st record.

The tab order is set appropriately.

I have tried to use setfocus and have it set to the txtOTHours on txtRegHrs update event and it works but it goes to the first record because the object shares the name property for all the records.

Should I be using a recordset to populate the subform and moving the cursor via code? If so, can someone steer me in the right direction?

Thanks in advance.

Mary Lou
 

Attachments

Last edited:
Looking at your pic, why are you using code to recalc the form? What is the control source of your total fields? - If it is set to =Sum([TimeWorked]) it should not need recalcing.
 
Hi Fizzio
I was using recalc to force the totals to update as soon as the field was changed.

The control source is an expression. The problem is that the total didn't refresh on field updates. It didn't happen until the user left the current record. If they were only entering one, they wouldn't see the calculated totals until the cmdSave button was pressed.

What occurred to me overnight is that I could use the requery method instead which doesn't reproduce the erratic behaviour.

Thanks for your help.
ML
 
Nope, I was wrong - requery does the same thing. It forces the total update but it also moves the query to the first record and the first field.

What should I do?
 
Save the record, then Requery the controls
DoCmd. RunCommand acCommandSaveRecord
Me.Recalc
 
Hi Rich,
Thanks for the suggestion but the same thing happens. When the recalc method is run, the cursor jumps back to the 1st record on the 1st field.

After I wrote that first paragraph, I thought hmmm...wonder what would happen if I used your save suggestion but excluded the recalc line and...it works fabulously!!!

Saving forces the summed control to update and the cursor moves more naturally.

Thank you.
ML
 
Last edited:

Users who are viewing this thread

Back
Top Bottom