can't get requery to work,

  • Thread starter Thread starter Don
  • Start date Start date
D

Don

I have a form with three tabs of which the first two have
subforms from queries. I'd like to requery one of the
subforms on tab 2 when a user selects it but am having
troubles getting it to work. I'd like to get the requery
to work first. Here is the code I've been trying:

Private Sub TabCtl35_Click()

Subform1 = "PUBLIC_CONCERN TAB2 Datasheet"
Me!Subform1.Form!PublicConcernNumber.Requery

End Sub

The subform that needs to be refreshed is "PUBLIC_CONCERN
TAB2 Datasheet". "PublicConcernNumber" is the first
control on the subform. In the debugger the following
message appears when it hits the Me!Subform1 line:

Run-time error '2465':
Databasename can't find the field 'Subform1' referred
to in your expression.


I'm new to Access so PLEASE feel free to give suggestions.

I'd then like to find if the requery could be attached to
the tab itself. Currently, I have to click inside the tab
area and not the tab part to get to the code. This
requires two clicks; one on the tab (to navigate there)
and one inside.

Thank you very much for your help!
 
Hi Don,

You need to requery the subform control -

me.MySub1.requery

where 'MySub1' is the name of the subform control. In design view click once
on the subform, then check the *name* property under the *Other* tab. What
you find there goes in place of "MySub1".

Note also that the Click event of the tab control does not work as you might
expect. It fires when you click somewhere on the tab control other than on a
tab (as you've already discovered). You need to use the "Change" event of
the tab control and check the tab control's value to know which page is
becoming visible.

The tabindex starts at 0 so here's how you check . . .


Private Sub TabCtl8_Change()

Select Case Me.TabCtl8
Case 0
msgbox "First Page"
Case 1
msgbox "Second"
Case 2
msgbox "Third"
Case 3
msgbox "Fourth"
End Select
End Sub
 
THANK you so much for replying and giving such good
examples!!!!! Got it to work!!!!! THANKS again!!!!
-----Original Message-----
Hi Don,

You need to requery the subform control -

me.MySub1.requery

where 'MySub1' is the name of the subform control. In design view click once
on the subform, then check the *name* property under the *Other* tab. What
you find there goes in place of "MySub1".

Note also that the Click event of the tab control does not work as you might
expect. It fires when you click somewhere on the tab control other than on a
tab (as you've already discovered). You need to use the "Change" event of
the tab control and check the tab control's value to know which page is
becoming visible.

The tabindex starts at 0 so here's how you check . . .


Private Sub TabCtl8_Change()

Select Case Me.TabCtl8
Case 0
msgbox "First Page"
Case 1
msgbox "Second"
Case 2
msgbox "Third"
Case 3
msgbox "Fourth"
End Select
End Sub

--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.

I have a form with three tabs of which the first two have
subforms from queries. I'd like to requery one of the
subforms on tab 2 when a user selects it but am having
troubles getting it to work. I'd like to get the requery
to work first. Here is the code I've been trying:

Private Sub TabCtl35_Click()

Subform1 = "PUBLIC_CONCERN TAB2 Datasheet"
Me!Subform1.Form!PublicConcernNumber.Requery

End Sub

The subform that needs to be refreshed is "PUBLIC_CONCERN
TAB2 Datasheet". "PublicConcernNumber" is the first
control on the subform. In the debugger the following
message appears when it hits the Me!Subform1 line:

Run-time error '2465':
Databasename can't find the field 'Subform1' referred
to in your expression.


I'm new to Access so PLEASE feel free to give suggestions.

I'd then like to find if the requery could be attached to
the tab itself. Currently, I have to click inside the tab
area and not the tab part to get to the code. This
requires two clicks; one on the tab (to navigate there)
and one inside.

Thank you very much for your help!


.
 
Back
Top