Subform requery Access 2007

Flynners

Registered User.
Local time
Today, 02:00
Joined
Mar 1, 2012
Messages
29
Hello there
I have a form in ms access 2007, with multiple tabs. Some of these tabs have subforms.
I want to update one subform from another but am having no joy. I cannot requery the second subform. ive read alot of threads about requery, referencing the main form and then subform2, the subform control name v's form name etc but still no joy.

Subform1 sets up the data displayed in subform2 - so depending on subfrom1 some fields in subform2 could be hidden or placed in a particular position on the form. I have this visible/not visible code in the onload event of subform2. This works well if the main form is closed after subform1 is updated. When i reopen the main form subform2 is displayed correctly.

I know the subforms are already "loaded" when the main form is opened but how can i get subform2 to reload when subform1 is updated. Should i have my formatting code of subform2 in a differnt event than onload? Is requery the correct command to use? when i want to esentially reload subform2.

any help would be appreciated.
:confused:
 
If you want another subform to update when another one is updated, you would need to have code to requery the second subform in the AFTER UPDATE event of the subform that is being updated.
 
I huse a method that goes into another screen - one to Amend and another enter new records. As another screen is use I can trigger an event onActivate.

Basically I have an Action Control On the Entry Button there is: .[Action] = "O" or .[Action] = "G" and on the Amend .[Action] = "A"

Then onActivate
Code:
Function Exhibitions_Activate()
    With CodeContextObject
        If IsNull(.[Action]) Then
            Exit Function
        ElseIf .[Action] = "A" Then
            DoCmd.RepaintObject acForm, "Exhibitions Entry"
        ElseIf .[Action] = "O" Then
            DoCmd.Requery "Exhibitions Originals"
        ElseIf .[Action] = "G" Then
            DoCmd.Requery "Exhibitions Prints"
        End If
        .[Action] = Null
    End With
End Function

Simon
 
Thanks Bob. Requery in the afterupdate of subform1 was what i need.

However it leads me onto another problem in subform2. The layout of subform2 is dependent on the data entered in subform1. I had code in the onload event of subform2 that hides "headings" if they are blank and move the next heading left by X number of twips. (headings come from data entered in subform1).
The onload event code that determines the layout didnt apply with the requery in the afterupdate of subform1

where should i put the code to manage the layout of subform2 when i cant use onload event. I cant put the code in the afterupdate on subform2 as i need the layout before data is entered on subform2. I dont think i can build this code into subform1.

Again thanks for your help
 
You could simply call the OnLoad procedure of the subform in question from the other one, if you change it from Private Sub to Public Sub.
 
Thanks Simon MT for your reply. I think I was too committed to the path I was on with my original code to try this. After update worked okay for me when I made a few adjustments to my onload control settings.
cheers
 

Users who are viewing this thread

Back
Top Bottom