Setting focus to main form

  • Thread starter Afrosheen via AccessMonster.com
  • Start date
A

Afrosheen via AccessMonster.com

Thanks for reading this. Here is my problem. I have two forms I'm working
with. Main menu form {frm_menu} and a sub form called frmbkbox which is
hidding.
The way the subform works is when I get to day 7 that subform appears and has
a button that you click on to perform the backup/copy. Clicking on the button
does perform the backup/copy. Where the problem comes up is when I try to
hide the subform after completion it will not let me because the focus is
still on the frmbackup. It gives me error 2165{You can't hide a control that
has the focus}. I need it to hide it. Here is what I've tried to do

Forms("frm_menu").SetFocus

Forms("frm_menu")!frmBKBox.Visible = False

On the first line I'm trying to set the focus back to the frm_menu.
On the second line I'm trying to hide the frmbkbox.

Thanks
 
A

Albert D. Kallal

You have to set the focus to a control.

try

me.parent.NameOfControl.SetFocus
me.visible = false

The above syntax should work.

You 1st line of code needs to be changed.

You 2nd line of code may work as written...
Forms("frm_menu")!frmBKBox.Visible = False

So, just set the focus to an actual control on the main form, and that
should do the trick...
 
A

Afrosheen via AccessMonster.com

Thanks Albert. That worked. I really appreciate the help I get from this
forum
 
L

Linq Adams via AccessMonster.com

The reason you have to use the workaround Mr.Kallal gave is another od
Access' quirks. A form can only receive focus if it holds no objects (command
buttons, textboxes, comboboxes, etc) that can recieve focus!

The form either has to be lacking any of these objects, or the objects have
to be formatted such as they cannot receive focus, such as if their Visible
Properties are set to Yes.
 

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