Tab Control select issue

S

Sandy

I have a tab control with the following proceudre for on the On Change Event:

Private Sub TabCtl0_Change()
DoCmd.Requery
End Sub

Everything work perfectly until someone clicks a SECOND time on the tab/page
that is ALREADY selected. The tab gets a light dashed line around it and many
of the menu items are greyed out. (sort, cut, paste and filter by selection
are examples)

The current record stays the same, but then the forms display the FIRST
record in the underlying table when you click any other tab.

This happens with every tab/page and there are no event procedure associated
with any of the page events so I am guessing that the Requery command is
running again, even though the page on the Tab Control is not changing

How do I prevent this from happening?

Many thanks,
sandra
 
T

tina

just what is it that you're requerying, specifically? and why - what result
are you after when you requery "the what"?

hth
 
S

Sandy

Thanks, Tina -

There are calculations on the forms that depend on data that is entered in
other forms.

s-
 
S

Stephen Lynch

Sand:

You could always go to the first tab, then requery the second tab and then
open the second tab. I have done this before, gotocontrol on tab one and
then to control on tab 2.

DoCmd.GoToControl "txtLocatedonTab1"
DoCmd.requery
DoCmd.GoToControl "txtLocatedonTab1"

or maybe
TabCtl1 = 1
DoCmd.requery
TabCtl1 = 2

Steve
 
J

Jim Burke in Novi

There may be be better ways of doing this, but you could create a
module-level variable in your form's module that keeps track of the current
tab - when the form is open set it to the tab number that is displayed when
the form is open. Then, in the On CHange event, check to see if the new tab
number value is the same as the previous one. If so, this means you're still
 
S

Sandy

Thanks Jim - I will try that.

I am not familiar with creating modules so I need a little help getting that
done.

Do I create the module in the same code window that is used for the main
form, or a separate module in the modules objects?


Here is an idea of what I think I need to do:

``````````````````
dim PageNum As Integer

pageNum = TabCtl0.Pages.Item(#PageNum#)

not sure how to get the #PageNum# into the PageNum variable?

``````````````````

Then for the OnChange Event on the TabControl:


``````````````````
Private Sub TabCtl0_Change()

dim PageNum As Integer

if PageNum <> TabCtl0.Pages.Item(PageNum) then

DoCmd.Requery

' else do nothing? does this need to be coded in???

end if

End Sub


``````````````````

Sorry for being such a nube :)

thanks!
s
 

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