take focus from subform

  • Thread starter vircalendar via AccessMonster.com
  • Start date
V

vircalendar via AccessMonster.com

I have a subform containing a datasheet (and only a datasheet). When a user
selects a record on the subform and clicks an "edit" button on the main form,
data from the selected field is copied to an unbound textbox on the main form
to be edited. What I would like to do is simultaneously lock and disable the
datasheet so that, once a record has been selected, the user can't select
another record until his edit is done or cancelled.

The problem is that I can't get the focus off the datasheet, so I can't
disable it. I've tried the sequence

me.form.setfocus
me.txtbox.setfocus

but I still get the "can't disable a control that has the focus" error.

I know I could use a form view instead of a datasheet view, and add a 0 space
control that is given the focus, thus allowing me to disable and lock the
field in question, but using a form view interferes with some other things
I'm doing and I would rather not do that.

I've tried coming at the problem from the other direction, using the
onlostfocus and onexit events of the textbox to trigger some code, but the
problem there is that I haven't been able to figure out whether the event is
firing because the user clicked "accept" or "cancel" buttons (which would be
okay) or whether he went back the the subform (which would not be).

Isn't there some way to completely remove the focus from a datasheet subform?
 
R

ruralguy via AccessMonster.com

When the user presses the CommandButton on the MainForm, that will also move
the focus to the MainForm. Have you tried just locking the SubFormControl?
 
V

vircalendar via AccessMonster.com

Yep. Same problem. Even though I have the focus clearly moved to an unbound
textbox on my main, the subform somehow or other doesn't give up the focus
completely.
When the user presses the CommandButton on the MainForm, that will also move
the focus to the MainForm. Have you tried just locking the SubFormControl?
I have a subform containing a datasheet (and only a datasheet). When a user
selects a record on the subform and clicks an "edit" button on the main form,
[quoted text clipped - 23 lines]
Isn't there some way to completely remove the focus from a datasheet subform?
 
R

ruralguy via AccessMonster.com

I don't use the Datasheet view so I don't have a sample to play with. I tried
it with the SubForm in Continuous Form mode without a problem. The
SubFormControl Enables and Disables with ease. What version of Access are you
using and on what OS?
Yep. Same problem. Even though I have the focus clearly moved to an unbound
textbox on my main, the subform somehow or other doesn't give up the focus
completely.
When the user presses the CommandButton on the MainForm, that will also move
the focus to the MainForm. Have you tried just locking the SubFormControl?
[quoted text clipped - 4 lines]
 
V

vircalendar via AccessMonster.com

Access 2033 SP3 and XP
I don't use the Datasheet view so I don't have a sample to play with. I tried
it with the SubForm in Continuous Form mode without a problem. The
SubFormControl Enables and Disables with ease. What version of Access are you
using and on what OS?
Yep. Same problem. Even though I have the focus clearly moved to an unbound
textbox on my main, the subform somehow or other doesn't give up the focus
[quoted text clipped - 5 lines]
 

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