Hidding a sub form on a tab

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

Afrosheen via AccessMonster.com

What I have is a tab control 0 that has a subform "frm_rostersub1" on it.
Another sub form "find" is hidden until I click on a command button. When I
press it "find" does "unhide". The problem is that when I click on the "Stop"
button that sub form "find" will not hide. This is what I have for code.

Forms!["frm_rostersub1"].cmdSave.SetFocus
Me.Visible = False

I've tried to set the focus away from the "find" form but it keeps on giving
me the error that it can't find the frm_rostersub1 form.

Thanks for your help and reply.
 
D

Dirk Goldgar

Afrosheen via AccessMonster.com said:
What I have is a tab control 0 that has a subform "frm_rostersub1" on it.
Another sub form "find" is hidden until I click on a command button. When
I
press it "find" does "unhide". The problem is that when I click on the
"Stop"
button that sub form "find" will not hide. This is what I have for code.

Forms!["frm_rostersub1"].cmdSave.SetFocus
Me.Visible = False

I've tried to set the focus away from the "find" form but it keeps on
giving
me the error that it can't find the frm_rostersub1 form.

Thanks for your help and reply.


If frm_rostersub1 is a subform on some other form, then it won't be in the
Forms collection. Am I right in understanding that both of the subforms you
are talking about, "frm_rostersub1" and "find", are subforms of the same
parent form? Is the Stop button you're talking about on the "find" subform?

If those conclusions are correct, then your code should look like this, I
think:

Me.Parent!frm_rostersub1.SetFocus
Me.Parent!frm_rostersub1.Form!cmdSave.SetFocus
Me.Parent!find.Visible = False

Please note: the above code assumes that "frm_rostersub1" and "find" are
the names of the subform controls involved; that is, the names of the
controls on the main form that provide the windows to the form objects they
display. Those names may or may not be the same as the names of the form
objects displayed by the subform controls.
 
A

Afrosheen via AccessMonster.com

Thanks for getting back to me Dirk.
The lay out I guess would be in this order

Tab control0 page
frm_rostersub1 - That is on the tab control page
find - That pops up {becomes visible} on the frm_rostersub1

I inserted your code, put a break in it and tried it.

Me.Parent!frm_rostersub1.SetFocus
Me.Parent!frm_rostersub1.Form!cmdSave.SetFocus
Me.Parent!find.Visible = False

The error still came up that it couldn't find frm_rostersub1. It stopped on
the first line. The thing is that there is a form called frm_rostersub1.

Question: Do you think it may have something to do with the underscore?


Dirk said:
What I have is a tab control 0 that has a subform "frm_rostersub1" on it.
Another sub form "find" is hidden until I click on a command button. When
[quoted text clipped - 11 lines]
Thanks for your help and reply.

If frm_rostersub1 is a subform on some other form, then it won't be in the
Forms collection. Am I right in understanding that both of the subforms you
are talking about, "frm_rostersub1" and "find", are subforms of the same
parent form? Is the Stop button you're talking about on the "find" subform?

If those conclusions are correct, then your code should look like this, I
think:

Me.Parent!frm_rostersub1.SetFocus
Me.Parent!frm_rostersub1.Form!cmdSave.SetFocus
Me.Parent!find.Visible = False

Please note: the above code assumes that "frm_rostersub1" and "find" are
the names of the subform controls involved; that is, the names of the
controls on the main form that provide the windows to the form objects they
display. Those names may or may not be the same as the names of the form
objects displayed by the subform controls.
 
A

Afrosheen via AccessMonster.com

Dirk, I did some tests just on the frm_rostersub1 without having it on the
tab control and it worked good. It must be something with the tab control.

Dirk said:
What I have is a tab control 0 that has a subform "frm_rostersub1" on it.
Another sub form "find" is hidden until I click on a command button. When
[quoted text clipped - 11 lines]
Thanks for your help and reply.

If frm_rostersub1 is a subform on some other form, then it won't be in the
Forms collection. Am I right in understanding that both of the subforms you
are talking about, "frm_rostersub1" and "find", are subforms of the same
parent form? Is the Stop button you're talking about on the "find" subform?

If those conclusions are correct, then your code should look like this, I
think:

Me.Parent!frm_rostersub1.SetFocus
Me.Parent!frm_rostersub1.Form!cmdSave.SetFocus
Me.Parent!find.Visible = False

Please note: the above code assumes that "frm_rostersub1" and "find" are
the names of the subform controls involved; that is, the names of the
controls on the main form that provide the windows to the form objects they
display. Those names may or may not be the same as the names of the form
objects displayed by the subform controls.
 
D

Dirk Goldgar

Afrosheen via AccessMonster.com said:
Thanks for getting back to me Dirk.
The lay out I guess would be in this order

Tab control0 page
frm_rostersub1 - That is on the tab control page
find - That pops up {becomes visible} on the frm_rostersub1

Ah, so the subform "find" is on "frm_rostersub1", which is a subform on the
main form. That makes a huge difference. You didn't say that before. Do
I have it right now?
I inserted your code, put a break in it and tried it.

Me.Parent!frm_rostersub1.SetFocus
Me.Parent!frm_rostersub1.Form!cmdSave.SetFocus
Me.Parent!find.Visible = False

The error still came up that it couldn't find frm_rostersub1. It stopped
on
the first line.

That code, as I stated when I posted it, was based on the understanding that
"find" and "frm_rostersub1" were both children of the same parent form. It
won't work if "find" is a subform of "frm_rostersub1".
The thing is that there is a form called frm_rostersub1.

That's not relevant -- we still have to build a chain of references that
locates it. We can work down through the main form, or up through the
subform's Parent property, but we have to locate the subform control that
displays "frm_rostersub1".
Question: Do you think it may have something to do with the underscore?

Nope. Incidentally, the tab control itself is not relevant to locating the
subform, because all the controls on the tab pages are also members of the
form's Controls collection.

Try the following code, which is based on the (new) understanding that
"find" is a subform of "frm_rostersub1", which is a subform of the main
form.

'------ start of code ------
Me.Parent!cmdSave.SetFocus
Me.Parent!find.Visible = False

'------ end of code ------
 
D

Dirk Goldgar

Afrosheen via AccessMonster.com said:
Dirk, I did some tests just on the frm_rostersub1 without having it on the
tab control and it worked good. It must be something with the tab control.


No, it isn't. Please read my reply to your other message.
 

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