Home All Groups Group Topic Archive Search About

Refresh data on form tab

Author
21 Nov 2007 10:42 AM
Andy
Hi
I have a form with 5 tabs. The first tab is editable, and the other 4 are
just reports relating to the data on the first. When I change the data on
the first form, this is not reflected in the other tabs. I've read, and
read, and read posts on here without success. The nearest I can see is
Me.Requery - but Access comes back with 'Macro not found'. Please point me
in the right direction! I always coped with Access (2000) but I must be
losing my touch with this one!
Thanks.

Author
21 Nov 2007 12:37 PM
Rick Brandt
Andy wrote:
> Hi
> I have a form with 5 tabs. The first tab is editable, and the other 4
> are just reports relating to the data on the first. When I change the
> data on the first form, this is not reflected in the other tabs. I've
> read, and read, and read posts on here without success. The nearest I
> can see is Me.Requery - but Access comes back with 'Macro not found'.
> Please point me in the right direction! I always coped with Access
> (2000) but I must be losing my touch with this one!
> Thanks.

Do the other tabs have subforms on them?  If so you need to issue a Requery on
the subforms.  If they just have calculated controls then Requery, Refresh, or
Recalc might all do what you want.

Sounds like you typed "Me.Requery" directly into the event property box.  That's
not how code events work.  In the event property box you type [Event Procedure]
and then press the build button [...] to the right.  That will take you to the
VBA code editor window and THAT is where Me.Requery goes.  In between the Sub
and End Sub lines that will be auto-created for you.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt   at   Hunter   dot   com
Author
21 Nov 2007 12:48 PM
Andy
Hi Rick - and thanks for the reply!!

I tried the Me.Requery in the OnClick of the tab. That doesn't work (as you
said it wouldn't). The only options on the subform are OnEnter and OnExit.
I'm not doing either of these (purely viewing) so where do I put the
Me.Requery? I don't want to requery the first tab, either, as I want it to
stay displaying the record that is already on it - not jump to the first
record.
Thanks.

Show quote
"Rick Brandt" <rickbran***@hotmail.com> wrote in message
news:rEV0j.73180$Um6.15998@newssvr12.news.prodigy.net...
> Andy wrote:
>> Hi
>> I have a form with 5 tabs. The first tab is editable, and the other 4
>> are just reports relating to the data on the first. When I change the
>> data on the first form, this is not reflected in the other tabs. I've
>> read, and read, and read posts on here without success. The nearest I
>> can see is Me.Requery - but Access comes back with 'Macro not found'.
>> Please point me in the right direction! I always coped with Access
>> (2000) but I must be losing my touch with this one!
>> Thanks.
>
> Do the other tabs have subforms on them?  If so you need to issue a
> Requery on the subforms.  If they just have calculated controls then
> Requery, Refresh, or Recalc might all do what you want.
>
> Sounds like you typed "Me.Requery" directly into the event property box.
> That's not how code events work.  In the event property box you type
> [Event Procedure] and then press the build button [...] to the right.
> That will take you to the VBA code editor window and THAT is where
> Me.Requery goes.  In between the Sub and End Sub lines that will be
> auto-created for you.
>
> --
> Rick Brandt, Microsoft Access MVP
> Email (as appropriate) to...
> RBrandt   at   Hunter   dot   com
>
Author
21 Nov 2007 1:18 PM
Rick Brandt
Andy wrote:
> Hi Rick - and thanks for the reply!!
>
> I tried the Me.Requery in the OnClick of the tab. That doesn't work
> (as you said it wouldn't). The only options on the subform are
> OnEnter and OnExit. I'm not doing either of these (purely viewing) so
> where do I put the Me.Requery? I don't want to requery the first tab,
> either, as I want it to stay displaying the record that is already on
> it - not jump to the first record.
> Thanks.

The OnClick of a TabPage is not what you think it is.  Use the Change event of
the entire TabControl.  You can use its Value property to determine which page
was just switched to.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt   at   Hunter   dot   com
Author
21 Nov 2007 2:14 PM
Andy
Hi Rick

I've got:

Private Sub TabCtl85_Change()
Select Case Me!TabCtl85.Value
    Case 1
    Forms!Form1!TabCtl85 = 1
    Me.Requery
    'do something else
End Select
End Sub

When I change a field on page 0 (the first page) and click on page 1, the
query/report does not show the changes I've just made. If I press F9 or
shift-F9 it does. When I go back to page 0, it has returned to the first
record (which I don't want) whether I've pressed F9 or not. That is the
reason that I tried the 'Forms!Form1!TabCtl85 = 1' bit in the above.
Thanks again!

Show quote
"Rick Brandt" <rickbran***@hotmail.com> wrote in message
news:PeW0j.73185$Um6.36931@newssvr12.news.prodigy.net...
> Andy wrote:
>> Hi Rick - and thanks for the reply!!
>>
>> I tried the Me.Requery in the OnClick of the tab. That doesn't work
>> (as you said it wouldn't). The only options on the subform are
>> OnEnter and OnExit. I'm not doing either of these (purely viewing) so
>> where do I put the Me.Requery? I don't want to requery the first tab,
>> either, as I want it to stay displaying the record that is already on
>> it - not jump to the first record.
>> Thanks.
>
> The OnClick of a TabPage is not what you think it is.  Use the Change
> event of the entire TabControl.  You can use its Value property to
> determine which page was just switched to.
>
> --
> Rick Brandt, Microsoft Access MVP
> Email (as appropriate) to...
> RBrandt   at   Hunter   dot   com
>
Author
21 Nov 2007 2:22 PM
Rick Brandt
Andy wrote:
> Hi Rick
>
> I've got:
>
> Private Sub TabCtl85_Change()
> Select Case Me!TabCtl85.Value
>    Case 1
>    Forms!Form1!TabCtl85 = 1
>    Me.Requery
>    'do something else
> End Select
> End Sub

Your Case 1 code is going to run when the user selects the tab page with an
index value of 1.  There is no reason for your code to then set the TabControl's
value to 1 (it already IS 1).

> When I change a field on page 0 (the first page) and click on page 1,
> the query/report does not show the changes I've just made. If I press
> F9 or shift-F9 it does. When I go back to page 0, it has returned to
> the first record (which I don't want) whether I've pressed F9 or not.
> That is the reason that I tried the 'Forms!Form1!TabCtl85 = 1' bit in
> the above. Thanks again!

You have to save the change made on Page 0 and then Requery the subform on Page
1...

Private Sub TabCtl85_Change()
    Select Case Me!TabCtl85.Value
        Case 1
            Me.Dirty = False
            Me.SubformControlName.Requery
    End Select
End Sub


--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt   at   Hunter   dot   com
Author
21 Nov 2007 3:35 PM
Andy
Hi Rick - and thanks again!
We're getting there. I've used your code and extended it for the other tabs.
It now looks like this:

Private Sub TabCtl85_Change()
    Select Case Me!TabCtl85.Value
        Case 1
            Me.Dirty = False
            Me.frmNonCP.Requery
        Case 2
            Me.Dirty = False
            Me.frmThisWeek.Requery
        Case 3
            Me.Dirty = False
            'Me.frmNextWeek.Requery
        Case 4
            Me.Dirty = False
            Me.frmWeekAfter.Requery
        Case 5
            Me.Dirty = False
            Me.frmLastWeek.Requery
        Case 6
            Me.Dirty = False
            Me.frmLastMonth.Requery
        Case 7
            Me.Dirty = False
            Me.frmThisMonth.Requery
End Select
End Sub

When I hit a tab (2nd one, for example) I get an error that the 'Method or
data member not found' and 'Me.frmNextWeek.Requery is highlighted (which is
why it's rem'd). When I rem it, the code errors on the next section on the
Me.frmWeekAfter.Requery line. All of the forms are within the database, and
work fine when they're not included in the script.

Cheers.

Show quote
"Rick Brandt" <rickbran***@hotmail.com> wrote in message
news:OaX0j.73207$Um6.46067@newssvr12.news.prodigy.net...
> Andy wrote:
>> Hi Rick
>>
>> I've got:
>>
>> Private Sub TabCtl85_Change()
>> Select Case Me!TabCtl85.Value
>>    Case 1
>>    Forms!Form1!TabCtl85 = 1
>>    Me.Requery
>>    'do something else
>> End Select
>> End Sub
>
> Your Case 1 code is going to run when the user selects the tab page with
> an index value of 1.  There is no reason for your code to then set the
> TabControl's value to 1 (it already IS 1).
>
>> When I change a field on page 0 (the first page) and click on page 1,
>> the query/report does not show the changes I've just made. If I press
>> F9 or shift-F9 it does. When I go back to page 0, it has returned to
>> the first record (which I don't want) whether I've pressed F9 or not.
>> That is the reason that I tried the 'Forms!Form1!TabCtl85 = 1' bit in
>> the above. Thanks again!
>
> You have to save the change made on Page 0 and then Requery the subform on
> Page 1...
>
> Private Sub TabCtl85_Change()
>    Select Case Me!TabCtl85.Value
>        Case 1
>            Me.Dirty = False
>            Me.SubformControlName.Requery
>    End Select
> End Sub
>
>
> --
> Rick Brandt, Microsoft Access MVP
> Email (as appropriate) to...
> RBrandt   at   Hunter   dot   com
>
Author
21 Nov 2007 3:55 PM
Rick Brandt
Andy wrote:
Show quote
> Hi Rick - and thanks again!
> We're getting there. I've used your code and extended it for the
> other tabs. It now looks like this:
>
> Private Sub TabCtl85_Change()
>    Select Case Me!TabCtl85.Value
>        Case 1
>            Me.Dirty = False
>            Me.frmNonCP.Requery
>        Case 2
>            Me.Dirty = False
>            Me.frmThisWeek.Requery
>        Case 3
>            Me.Dirty = False
>            'Me.frmNextWeek.Requery
>        Case 4
>            Me.Dirty = False
>            Me.frmWeekAfter.Requery
>        Case 5
>            Me.Dirty = False
>            Me.frmLastWeek.Requery
>        Case 6
>            Me.Dirty = False
>            Me.frmLastMonth.Requery
>        Case 7
>            Me.Dirty = False
>            Me.frmThisMonth.Requery
> End Select
> End Sub
>
> When I hit a tab (2nd one, for example) I get an error that the
> 'Method or data member not found' and 'Me.frmNextWeek.Requery is
> highlighted (which is why it's rem'd). When I rem it, the code errors
> on the next section on the Me.frmWeekAfter.Requery line. All of the
> forms are within the database, and work fine when they're not
> included in the script.

In that code the identifier following Me. needs to be the name of the subform
*control* which might not be the same as the name of the form it references.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt   at   Hunter   dot   com
Author
21 Nov 2007 4:00 PM
Douglas J. Steele
Show quote
"Rick Brandt" <rickbran***@hotmail.com> wrote in message
news:0yY0j.73224$Um6.48085@newssvr12.news.prodigy.net...
> Andy wrote:
>> Hi Rick - and thanks again!
>> We're getting there. I've used your code and extended it for the
>> other tabs. It now looks like this:
>>
>> Private Sub TabCtl85_Change()
>>    Select Case Me!TabCtl85.Value
>>        Case 1
>>            Me.Dirty = False
>>            Me.frmNonCP.Requery
>>        Case 2
>>            Me.Dirty = False
>>            Me.frmThisWeek.Requery
>> End Select
>> End Sub
>>
>> When I hit a tab (2nd one, for example) I get an error that the
>> 'Method or data member not found' and 'Me.frmNextWeek.Requery is
>> highlighted (which is why it's rem'd). When I rem it, the code errors
>> on the next section on the Me.frmWeekAfter.Requery line. All of the
>> forms are within the database, and work fine when they're not
>> included in the script.
>
> In that code the identifier following Me. needs to be the name of the
> subform *control* which might not be the same as the name of the form it
> references.


I believe it should be Me.NameOfSubformControl.Form.Requery

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
Author
21 Nov 2007 4:08 PM
Rick Brandt
Douglas J. Steele wrote:
> I believe it should be Me.NameOfSubformControl.Form.Requery

That will also work, but I have never had a problem just issuing the Requery on
the control.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt   at   Hunter   dot   com
Author
21 Nov 2007 4:18 PM
Andy
Thank you, thank you, thank you!!!

I often post replies in the Excel forums and I know what it's like to solve
something for someone. Now I know it's just as nice to be the 'someone' who
has something solved for them!

Cheers.

Show quote
"Rick Brandt" <rickbran***@hotmail.com> wrote in message
news:uKY0j.73227$Um6.65857@newssvr12.news.prodigy.net...
> Douglas J. Steele wrote:
>> I believe it should be Me.NameOfSubformControl.Form.Requery
>
> That will also work, but I have never had a problem just issuing the
> Requery on the control.
>
> --
> Rick Brandt, Microsoft Access MVP
> Email (as appropriate) to...
> RBrandt   at   Hunter   dot   com
>
>
>

AddThis Social Bookmark Button