Control on a Tab Page

  • Thread starter Thread starter New Kid on ADP Block
  • Start date Start date
N

New Kid on ADP Block

I'm trying to do a little "trickery" to eliminate some UI
features that the users of a ADP (done by someone else)
don't like. Access 2000, Win 2000 Pro, and SQL Server
2000, if that makes any difference.

One thing I need to do is to move an unbound text box over
any text box on the form that gets focus... it should, I
thought, be a simple matter of replacing the Top and Left
properties of the unbound text box with the Top and Left
properties of the clicked text box.

That works fine until I click a text box that is on a tab
page. Its top and left appear to be relative to the tab
page and I haven't found a property that will tell me (1)
that it is on the tab page, (2) which tab page / control
it is on, and so I can't figure out what to add to its Top
and Left to locate it properly.

I wrote code to print the properties and value of the
properties of the text box... it appears to have 81
properties, and I'm about to review the printed list, but
didn't see anything onscreen that caught my eye as showing
(1) or (2) above.

Any help gratefully appreciated.

New Kid
 
New Kid on ADP Block said:
I'm trying to do a little "trickery" to eliminate some UI
features that the users of a ADP (done by someone else)
don't like. Access 2000, Win 2000 Pro, and SQL Server
2000, if that makes any difference.

One thing I need to do is to move an unbound text box over
any text box on the form that gets focus... it should, I
thought, be a simple matter of replacing the Top and Left
properties of the unbound text box with the Top and Left
properties of the clicked text box.

That works fine until I click a text box that is on a tab
page. Its top and left appear to be relative to the tab
page and I haven't found a property that will tell me (1)
that it is on the tab page, (2) which tab page / control
it is on, and so I can't figure out what to add to its Top
and Left to locate it properly.

I wrote code to print the properties and value of the
properties of the text box... it appears to have 81
properties, and I'm about to review the printed list, but
didn't see anything onscreen that caught my eye as showing
(1) or (2) above.

Any help gratefully appreciated.

New Kid

Interesting question. Each unattached control on a tab page has that
page as its parent. So, speculatively ...

Dim lngPageTop As Long
Dim lngPageLeft As Long
Dim lngCtlTop As Long
Dim lngCtlLeft As Long

With Me!txtMyTextBox

If TypeOf .Parent Is Page Then
' txtMyTextBox is on a tab page.
lngPageTop = .Parent.Top
lngPageLeft = .Parent.Left
Else
lngPageTop = 0
lngPageLeft = 0
End If

lngCtlTop = .Top + lngPageTop
lngCtlLeft = .Left + lngPageLeft

End With
 
Interesting question. Each unattached control
on a tab page has that page as its parent. So,
speculatively ...

Thank you, Dirk. I thought I had looked for and tested for
the property and found there wasn't one. But, I tried
again after reading your post and it's there, big as life.
This will simplify the way I was doing it.

Thanks again.

New Kid
 
Oh, am I ever embarrassed! I jumped to conculsions... the
top and left of controls on a tab page are not measured as
offsets from the tab page, but from the section. It was
not having the control I wanted to relocate in the same
(detail) section that was causing me problems.

Thanks for your response and my apologies for the
unnecessary work to which I put you.

Blushing, Embarrassed New Kid
 
"Embarrassed New Kid on ADP Block"
Oh, am I ever embarrassed! I jumped to conculsions... the
top and left of controls on a tab page are not measured as
offsets from the tab page, but from the section. It was
not having the control I wanted to relocate in the same
(detail) section that was causing me problems.

Ah, that makes more sense. I admit I didn't look into it all that
closely.
Thanks for your response and my apologies for the
unnecessary work to which I put you.

Think nothing of it. Maybe the information will be useful to someone
else some day. And thanks for posting back with the correction.
 
I'm embarrassed and sorry to have wasted your time.

I thought I had tested for a Parent property, but
retesting showed that there was one, and it referred to
the proper tab page.

I jumped to a wrong conclusion -- the control on the tab
page was not offset by the Top and Left of the tab page.
It was just a matter that I was resetting the position of
the unbound text box that was located in a different
Section of the form.

The Top and Left are relative to the Section in which the
Control resides.

At least, I have learned something.

New Kid
 
Back
Top