SetFocus overridden by pass value code

noboffinme

Registered User.
Local time
Today, 21:12
Joined
Nov 28, 2007
Messages
288
Hi

I have a form (main) containing a subform (question) with 2 text box controls (Q_1 & H_1).

On every Click & After Update event on either of these textboxes values are passed to textboxes on the main form, these values ensure other subforms select the correct records pertaining to the subform.

All is fine apart from the code seems to force the focus to end up in the first textbox 'Q_1' after the events.

Adding code to the 'H_1' to setfocus to it is overidden by this pass value code as when I remove it, the form naturally works normally.

The user experience is that they move from the 'Q_1' field to the 'H_1' field to enter data & the code moves the cursor back to the 'Q_1' field.

Only using tab will move the cursor to the 'H_1' field.

How can code that just passes values have this effect on a cursor behaviour??

Here's the code to pass the values;

Note - 'main_q_no' sits on the main form & has its value set

Forms!frm_main.main_q_no = Me.Q_1
Forms!frm_main.main_q_id = Me.q_id

Adding a Setfocus back to the correct field will only last until the code runs & the cursor jumps back to 'Q_1' every time, Adding Me.NextTextBox also doesn't help.

Thanks
 
Hi VbaInet

No, no requerying happens.

Just the pass value code prompts this behaviour somehow, if I remove this pass a value code, it behaves fine.
 
Are main_q_no and main_q_id field names or control names, or both?
 
They are unbound controls (TextBoxes) that sit on the main form.
The Click & After Update event on the subform textboxes passes their value (Number) to these textboxes & other subforms read them.

The form & all subforms operate perfectly apart from this annoying behaviour, I can live with it by tabbing down to the next textbox but I thought there might be something I'm not aware of that is a known issue & causes this to occur.

As soon as I remove that passing value code (no other changes) it all works fine. :confused:
 
We would need to see (a stripped down version of) your db to understand what is going on and how it can be curbed.
 

Users who are viewing this thread

Back
Top Bottom