setting the focus to a nested subform

A

accesswanabe

This thing is going to make me rip what little hair I have right out...

Okay, I have a main form. On the main form, I have a subform and, on that
subform, an additional nested subform. I'm trying to set the focus to a
control on the nested subform, but can't get it to work. I've added the
following lines as researched on-line:

Forms![Main].Form!Preview.SetFocus
Forms![Main].Form!Preview.Form![EstimatesSub].SetFocus
Forms![Main].Form!Preview.Form![EstimatesSub].form![ServiceType].SetFocus

Here's the rub...upon code execution, the expected control does not appear
to have the focus; there's no cursor or highlight at all on the control.
But, when I press the delete key (discovered this behavior by mistake) the
data in the control that I intended to have the focus gets deleted. Of
course, at that point the control really does have the focus...but I really
need my data.

My intent is to set the focus prior to making a search feature available
thereby saving my users some keystrokes...just can't seem to get that control
fully exposed.

Anyone have any ideas? Sure appreciate it.
 
A

Allen Browne

So, the problem is with the Access interface painting: the correct control
is active, but Access doesn't show it correctly.

Wonder if it would make any difference if you reversed the order of your 3
lines of code?

Or even:
Me.Repaint
 
A

accesswanabe

Thanks Allen! I appreciate the quick response very much.

I tried repainting at the nested subform...it's not available at the control
for some reason. No good...

I reversed the lines and that didn't work either. The control data no
longer "deletes" which makes me think that reversing the lines does not help
the situation. Is there something I'm not thinking of with the reverse?


Allen Browne said:
So, the problem is with the Access interface painting: the correct control
is active, but Access doesn't show it correctly.

Wonder if it would make any difference if you reversed the order of your 3
lines of code?

Or even:
Me.Repaint

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.
accesswanabe said:
This thing is going to make me rip what little hair I have right out...

Okay, I have a main form. On the main form, I have a subform and, on that
subform, an additional nested subform. I'm trying to set the focus to a
control on the nested subform, but can't get it to work. I've added the
following lines as researched on-line:

Forms![Main].Form!Preview.SetFocus
Forms![Main].Form!Preview.Form![EstimatesSub].SetFocus
Forms![Main].Form!Preview.Form![EstimatesSub].form![ServiceType].SetFocus

Here's the rub...upon code execution, the expected control does not appear
to have the focus; there's no cursor or highlight at all on the control.
But, when I press the delete key (discovered this behavior by mistake) the
data in the control that I intended to have the focus gets deleted. Of
course, at that point the control really does have the focus...but I
really
need my data.

My intent is to set the focus prior to making a search feature available
thereby saving my users some keystrokes...just can't seem to get that
control
fully exposed.

Anyone have any ideas? Sure appreciate it.
 
A

accesswanabe

Just figured something else out...

When I mouse click on the nested subform in an area where there are no
controls except the subform control, the control I want to manipulate becomes
instantly focused; the data is fully highlighted and my search functionlity
works correctly.

Wierd..

Allen Browne said:
So, the problem is with the Access interface painting: the correct control
is active, but Access doesn't show it correctly.

Wonder if it would make any difference if you reversed the order of your 3
lines of code?

Or even:
Me.Repaint

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.
accesswanabe said:
This thing is going to make me rip what little hair I have right out...

Okay, I have a main form. On the main form, I have a subform and, on that
subform, an additional nested subform. I'm trying to set the focus to a
control on the nested subform, but can't get it to work. I've added the
following lines as researched on-line:

Forms![Main].Form!Preview.SetFocus
Forms![Main].Form!Preview.Form![EstimatesSub].SetFocus
Forms![Main].Form!Preview.Form![EstimatesSub].form![ServiceType].SetFocus

Here's the rub...upon code execution, the expected control does not appear
to have the focus; there's no cursor or highlight at all on the control.
But, when I press the delete key (discovered this behavior by mistake) the
data in the control that I intended to have the focus gets deleted. Of
course, at that point the control really does have the focus...but I
really
need my data.

My intent is to set the focus prior to making a search feature available
thereby saving my users some keystrokes...just can't seem to get that
control
fully exposed.

Anyone have any ideas? Sure appreciate it.
 
A

Allen Browne

Are you working in a form where:
a) no new records can be added (there's no 'new record' row), and
b) there may be no records to show?

If so, Access certainly does have problems with that form. Here's more info:
http://allenbrowne.com/bug-06.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

accesswanabe said:
Just figured something else out...

When I mouse click on the nested subform in an area where there are no
controls except the subform control, the control I want to manipulate
becomes
instantly focused; the data is fully highlighted and my search
functionlity
works correctly.

Wierd..

Allen Browne said:
So, the problem is with the Access interface painting: the correct
control
is active, but Access doesn't show it correctly.

Wonder if it would make any difference if you reversed the order of your
3
lines of code?

Or even:
Me.Repaint

accesswanabe said:
This thing is going to make me rip what little hair I have right out...

Okay, I have a main form. On the main form, I have a subform and, on
that
subform, an additional nested subform. I'm trying to set the focus to
a
control on the nested subform, but can't get it to work. I've added
the
following lines as researched on-line:

Forms![Main].Form!Preview.SetFocus
Forms![Main].Form!Preview.Form![EstimatesSub].SetFocus
Forms![Main].Form!Preview.Form![EstimatesSub].form![ServiceType].SetFocus

Here's the rub...upon code execution, the expected control does not
appear
to have the focus; there's no cursor or highlight at all on the
control.
But, when I press the delete key (discovered this behavior by mistake)
the
data in the control that I intended to have the focus gets deleted. Of
course, at that point the control really does have the focus...but I
really
need my data.

My intent is to set the focus prior to making a search feature
available
thereby saving my users some keystrokes...just can't seem to get that
control
fully exposed.
 
A

accesswanabe

I have "Allow Additions" set to yes and there are always records that display
in the detail area of the form. Also, there are no filters applied or
anything like that.

I tried to programmatically "click" the subform, but that didn't work either.

Thanks again, Allen.

Allen Browne said:
Are you working in a form where:
a) no new records can be added (there's no 'new record' row), and
b) there may be no records to show?

If so, Access certainly does have problems with that form. Here's more info:
http://allenbrowne.com/bug-06.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

accesswanabe said:
Just figured something else out...

When I mouse click on the nested subform in an area where there are no
controls except the subform control, the control I want to manipulate
becomes
instantly focused; the data is fully highlighted and my search
functionlity
works correctly.

Wierd..

Allen Browne said:
So, the problem is with the Access interface painting: the correct
control
is active, but Access doesn't show it correctly.

Wonder if it would make any difference if you reversed the order of your
3
lines of code?

Or even:
Me.Repaint

This thing is going to make me rip what little hair I have right out...

Okay, I have a main form. On the main form, I have a subform and, on
that
subform, an additional nested subform. I'm trying to set the focus to
a
control on the nested subform, but can't get it to work. I've added
the
following lines as researched on-line:

Forms![Main].Form!Preview.SetFocus
Forms![Main].Form!Preview.Form![EstimatesSub].SetFocus
Forms![Main].Form!Preview.Form![EstimatesSub].form![ServiceType].SetFocus

Here's the rub...upon code execution, the expected control does not
appear
to have the focus; there's no cursor or highlight at all on the
control.
But, when I press the delete key (discovered this behavior by mistake)
the
data in the control that I intended to have the focus gets deleted. Of
course, at that point the control really does have the focus...but I
really
need my data.

My intent is to set the focus prior to making a search feature
available
thereby saving my users some keystrokes...just can't seem to get that
control
fully exposed.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top