Can't set focus on subform control

Status
Not open for further replies.

Galaxiom

Super Moderator
Staff member
Local time
Tomorrow, 06:33
Joined
Jan 20, 2009
Messages
12,832
A form has a subform control whose Source Object is a query. This query returns records from a very large table and has totals on some fields. As such it takes quite a while to fully load.

After opening the main form I can move the focus to the subform control as part of a set of VB procedures.

However opening the form programatically and immediately running the same procedures results in an error while attempting to move the focus to the subform control. If the form is already open, the same command is completed without complaint.

I expect this is matter of timing with the SetFocus command executed immediately on the form completing its load but before the subform has a chance to finish.

Is there a way to check the subform is fully loaded before proceeding?
Would using a form as the subform Source Object be likely to make any difference?

Remembering the other limitations I have encountered with using a query or table rather than a form as a Source Object in subform controls, perhaps I have another reason not to use them.

However I am reluctant to make the change without good reason since the present technique works fine otherwise and it would achieve very little if it didn't fix this focus problem.
 
How about posting what code you are using to programatically move the focus so we can look at it?
 
I have now discovered that the problem is not about any difference between setting the focus by clicking manually or using code.

Nothing on the form will work properly until a second click. If the first click is made on the subform it will return exactly the same error as trying to set the focus on the subform programatically. I get errors if the first click is on a combobox.

I'm continuing here:
http://www.access-programmers.co.uk/forums/showthread.php?p=862072#post862072
 
Running us around to different threads is not particularly helpful here. Try importing your db into a new fresh db. You could also try a /decompile.
 
Running us around to different threads is not particularly helpful here.

I began with this thread. The other thread was started separately in good faith on what ultimately turned out on further investigation to be another symptom of the same problem.

At this point I had two threads on the same problem. I had a choice to either post the link or pretend they were separate issues and let people waste their time working with half the information.

I chose the link to the other thread because it dealt with the broader manifestation. I also referenced this thread from there. I really don't think there was a better way to handle it.
 
I guess you are right considering how it sort of grew. Did you try my suggestions?
 
Status
Not open for further replies.

Users who are viewing this thread

Back
Top Bottom