Can not move focus from a popup form (1 Viewer)

daveinhull

Registered User.
Local time
Today, 03:36
Joined
Mar 4, 2014
Messages
22
Hi all

Hoping someone can help.
I have a sub form that opens a popup form to display some further information as the user continues to type in the control on the sub form. But the cursor disappears from the sub form cobtrol to the popup control and I have to click the sub form control to get the cursor back to continue typing.
What happens is that when the user enters the sub form text box control the on got focus event opens the popup form which has just one text box control on it.
I've tried setting focus back to the sub form control after opening the popup and I've tried setting focus to the sub form control in the popup form, but neither works.

I don't think set focus will actually work because I suspect the control on the sub form hadn't actually lost focus. I've tried therefore setting the focus back to the sub form, but that doesn't work either.

I also don't think the sub form loses focus either because the lost focus event for the sub form doesn't fire.

I've looked everywhere and seen some similar questions but never any solutions.

Does anyone have any thoughts on this?

Many thanks in advance
Dave
 
Last edited:

theDBguy

I’m here to help
Staff member
Local time
Today, 03:36
Joined
Oct 29, 2018
Messages
21,454
Hi. Can you post the code you're using in the Focus event of the textbox to open the popup form? Are you using acDialog?
 

Galaxiom

Super Moderator
Staff member
Local time
Today, 20:36
Joined
Jan 20, 2009
Messages
12,851
The cursor moves to the popup form so it obviously has the focus..
Set focus to the main form, then the subformcontrol, then the textbox.
 

daveinhull

Registered User.
Local time
Today, 03:36
Joined
Mar 4, 2014
Messages
22
@theDBguy
Sorry it wasn't on 'On Got Focus' I was using 'On Enter'. The code is quite simple:
Code:
DoCmd/OpenForm "ChineseText", acNormal
Forms!ChineseText.Form!Chinese = TxWord.Text
After this, I was also trying various methods to set focus back to the test box, e.g.
Code:
me.SetFocus
...or
txWord.SetFocus
...or
forms!main.form!org_Practice_findings.form!txWord.SetFocus
...or
forms!main..form!org_Practice_findings.SetFocus
txWord.SetFocus
...and multiple combinations
I also tried putting similar in an event in the pop-up form (ChineseText)

Thanks
Dave
 

daveinhull

Registered User.
Local time
Today, 03:36
Joined
Mar 4, 2014
Messages
22
@Galaxiom
The cursor moves to the popup form so it obviously has the focus..
I agree, but the txWord control which opens the popform does not have its 'On Lost Focus' event fire, nor the 'On Exit' event, so surely it still has focus in some way? Although I have not looked at whether its subform or its main form has the events fired or not.
Set focus to the main form, then the subformcontrol, then the textbox.
I have tried setting focus to the subform and then the control and that didn't work, but I've not tried all three, will give that a go.

Thanks
Dave
 

daveinhull

Registered User.
Local time
Today, 03:36
Joined
Mar 4, 2014
Messages
22
@Galaxiom,

My goodness what a faf, but it worked, many thanks
Code for anyone else with this issue which worked
Code:
   DoCmd.OpenForm "ChineseText", acNormal
   Forms!Main.SetFocus
   Forms!Main.Form!Org_Practice_Findings.SetFocus
   Forms!Main.Form!Org_Practice_Findings.Form!TxWord.SetFocus
I was half way there, but never thought to have to also set focus to the main form first, but in thinking about it, it makes absolute sense.

Many many thanks
Dave
 

isladogs

MVP / VIP
Local time
Today, 11:36
Joined
Jan 14, 2017
Messages
18,209
Possibly an easier approach is to have an unattached label on the subform.
When the user enters your subform control for data entry, make the label visible with its caption being whatever your message box shows.
On leaving the control, hide the label again.
The same label with different captions can be used for more than one purpose if needed
 

daveinhull

Registered User.
Local time
Today, 03:36
Joined
Mar 4, 2014
Messages
22
@isladogs,

Yes I did think of that, but the subform is a small part of the overal main form and doesn't really have enough space for a seperate label or text box within it. The popup form is the same size as the subform text control as I'm trying to implement real-time translation into another language. So when the use is entering text into the subform text control, it is being translated into another langauge inthe popup form. All the translation works well through calls to the google tranlsator API whenever the subform text control changes.

The only worry I have is delays from the API. I have a fast internet, but this isn't the problem, its delays from the google side or delays simply over the network. It certainly works for me, but I'll have to see in pracitce. I may either introduce a timed delay so that it only updates the translation every 5 or 10 seconds or ulimately only when I hit return or some other charcter or event.

Thanks for takling the time to make the suggestion.
Dave
 

isladogs

MVP / VIP
Local time
Today, 11:36
Joined
Jan 14, 2017
Messages
18,209
I use Google translate with several of my apps. For example
I have slow internet yet don't experience the delays that you're describing.

However, in most of my applications, translation is used for captions, message boxes and input boxes.
Why do you need to translate the entered data?
 

daveinhull

Registered User.
Local time
Today, 03:36
Joined
Mar 4, 2014
Messages
22
Hi,

I haven't experienced any delays I was just worried that I might, in fact it works really well. Glad to hear that you haven't experienced delays.

I use my app to collect audit results from an audit team and then we consolidate individual findings into a single statement. I often do this with foreign team membets and currently I type the single statement in English (screen sharing over a confernce call). When I'm finished my translator read it to the foriegn team members. This works well and of course a human translator is more accurate and faithful to the English meaning than Google Translate is. However, I thought it would be useful (fun) to show them in real time what I was trying to create - of course as I'm typing and with my usual spelling mistakes it could be rather interesting what they see🙄😂

Dave
 

isladogs

MVP / VIP
Local time
Today, 11:36
Joined
Jan 14, 2017
Messages
18,209
It sounds like you are planning to use the Change event so it updates after each character is entered. I would recommend using the After Update event instead
 

daveinhull

Registered User.
Local time
Today, 03:36
Joined
Mar 4, 2014
Messages
22
Thought of that but as I'm creating the single statement it is updated changed deleted added as I'm trying to put together the final statement all of which I'm in the text control, hence why I'd going to do it on a character by character basis. It does work rraly well. I'd have to leave the control for the after update to work and by that time the human translator would do a propper translation. I guess I'm just trying to keep the other team members interested while the statement is created, they may giggle a bit, especially when it's Chinese

Dave
 
Last edited:

Users who are viewing this thread

Top Bottom