Requery a subform from another subform

sclemens

New member
Local time
Today, 23:09
Joined
May 8, 2014
Messages
4
There are a lot of post about this, but even with all the tips it's still not working.

I have a main form with a couple of tabs, forms and subforms (see attachment). The problem is that when I click on one of the blue record navigators, I want the right subform to requery. I can't get that to function properly.

Until now I'm just using the Macro Builder and little to no VBA. There is a function Requery in the MB, but I keep getting error messages that the object doesn't exist or nothing happens at all.

I've read the page on Access mvps about linking to forms, but I'm still doing something wrong.

When I used some VB like:
Me.Parent!frmStagesPerLeerling2.Form.Requery

it did work, but I an into problems with setting the visibility of the navigation buttons (they should only show when there is more then one record in that subform).

I hope someone can help me.
 

Attachments

  • 2014-05-08_11h39_37.png
    2014-05-08_11h39_37.png
    87.6 KB · Views: 298
Sorry, I thought the image would clarify that, but it's like this:

Main form: Leerlingmanagementsysteem
Subform: FrmLeerlingGegevens
Sub-sub-form with the record navigators: sfrmOpleidingenPerLeerlingUitgebreid
Sub-sub-form I want to requery: sfrmStageDetails
 
I fixed it myself. I'm using this VBA on the form with the buttons:

Code:
Private Sub Form_Current()

If Me.Parent.AantalOpleidingenLeerling <> 1 Then
Me.Parent!frmStagesPerLeerling2.Form.Requery
Me.btnhidden.SetFocus
Else
Me.btnhidden.SetFocus
End If

End Sub

To explain the code a little:
On the main form there is a field (AantalOpleidingenLeerling) with the number of records on the subform at the bottom of the screen. When that value is equal to 1 there are no navigation buttons, so it should only remove the focus. Otherwise it should requery the right subform.
I had to create a hidden button on the form and add the SetFocus to that button to avoid the error: "You cant hide a control that has Focus" when a user would have clicked one of the navigation buttons and switched to another user after that.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom