Form 1 opens form 2, but focus stays on form1? (1 Viewer)

theKruser

Registered User.
Local time
Today, 11:57
Joined
Aug 6, 2008
Messages
122
As mentioned, I have frm1 and frm2. When certain criteria are met in frm1, frm2 opens (pop up, non-modal) to remind the employee there are additional steps needed.

The problem is, the trigger for the frm2 open event happens as the employee is receiving/transcribing information at a very rapid pace. In the time it takes to take your hand off the keyboard, click the mouse to return focus to frm1, and return to the keyboard, 3-4 fields-worth of information has been passed that the employee will not be able to enter.

I have tried putting the following code in various events in frm2 to no avail:

Code:
[Forms]![frm1]![sbf1].[Form]![sbf1ControlName]

Any help would be greatly appreciated.
 

vbaInet

AWF VIP
Local time
Today, 16:57
Joined
Jan 22, 2010
Messages
26,374
So you're saying you want the code to pause and wait for frm2 to close before it continues?
 

theKruser

Registered User.
Local time
Today, 11:57
Joined
Aug 6, 2008
Messages
122
No. Looking for frm2 to basically just pop up (without taking focus) and stay open as a reminder. It pops up on the right side of the screen out of the way.

It also serves as a verification that the employee was reminded to follow a series of steps required when certain criteria are met.
 

vbaInet

AWF VIP
Local time
Today, 16:57
Joined
Jan 22, 2010
Messages
26,374
If it opens it must take focus because that's default behaviour. You need to return focus back to your frm1 after opening frm2.

Use DoCmd.SelectObject to set focus back to frm1.
 

theKruser

Registered User.
Local time
Today, 11:57
Joined
Aug 6, 2008
Messages
122
Thank you for the help! I have tried placing the following codes (at different times of course) in the OnLoad, OnOpen, AfterRender, and AfterFinalRender events of frm2 and sbf2, but it is not setting the focus back to frm1:

Code:
DoCmd.SelectObject acForm, "frm1"

Code:
DoCmd.SelectObject acForm, "sbf1"

Admittedly, I am not certain what the Render events do (one would deduce they render something...hahaha), but I will research that separately.

What am I doing wrong?
 

theKruser

Registered User.
Local time
Today, 11:57
Joined
Aug 6, 2008
Messages
122
Wow...just looked up the render events. I was WAY off.
 

vbaInet

AWF VIP
Local time
Today, 16:57
Joined
Jan 22, 2010
Messages
26,374
Code to open form 2, followed by SelectObject. That's the order. I'm guessing this is in the Click event of the button.

Render is for graphs.
 

theKruser

Registered User.
Local time
Today, 11:57
Joined
Aug 6, 2008
Messages
122
You, sir, are a genius!!

Thank you very much for your help. Have a great day!!
 

billmh

New member
Local time
Today, 18:57
Joined
Sep 23, 2011
Messages
5
I have a similar problem. I have a form that has two list boxes and a textbox. When the form opens The first item is selected in the first listbox which lists related items in the second and the first item is selected, which puts a value to the textbox.

All works as it should on opening. I can see the first listbox has the focus and the first items are highlighted in both listboxes. The setup of these boxes are established in the On Open of the form.

If I use the down arrow key, the _Click event is fired for the first list box. Which should select the second item and update the following boxes. However, the test for the selected item is still the first item in the list so, the following boxes remain the same. If I press the down arrow a second time everything updates accordingly.

Its like the listbox has the focus, but the first item does not, though it is highlighted. A similar thing happens if I TAB from the first box to the second and then hit the down arrow key there. I have to do it twice.

Here is the On Open code: Note the LstTrailer is setup by a default query for the listbox

Me.lstTrailer.Selected(0) = True

Trailer = Me.lstTrailer.Column(0)

(Tubelst is a query that builds the list for the second listbox based on TRAILER)

Me.lstTubes.RowSource = Tubelst
Me.lstTubes.Selected(0) = True

Me.txtTrTubeCom = Me.lstTubes.Column(1) ' txtbox value entered

The _Click event for the the first listbox lstTrailer is the same code as above. It all works well with subsequent arrow keystrokes.
 
Last edited:

vbaInet

AWF VIP
Local time
Today, 16:57
Joined
Jan 22, 2010
Messages
26,374
billmh, this isn't a related question. It is normal practice on this forum for members to create a new thread when asking a question and if you feel the need to, you can reference this thread in yours.
 

missinglinq

AWF VIP
Local time
Today, 11:57
Joined
Jun 20, 2003
Messages
6,420
...frm2 opens (pop up, non-modal) to remind the employee there are additional steps needed...
...Looking for frm2 to basically just pop up (without taking focus) and stay open as a reminder.
If the purpose of frm2 is merely informative, why not simply use a Label instead of a Form and control its Visibilty, as needed?

Linq ;0)>
 

Users who are viewing this thread

Top Bottom