Update of Subform in datasheet view on mainform?

Compressor

Registered User.
Local time
Today, 18:43
Joined
Sep 23, 2006
Messages
118
Hi,

I have a query (SelectedData_Query) , on which a form (SelectedDataQuery_SubForm) in datasheetview is based, which is placed on a form (NAWInvoerForm) where customer adress data is put in. When someone clicks new case button on the NAWInvoer_Form, another form (CaseDateTimeInfo_Form) is opened, data is entered, but when the "CaseDateTimeInfo_Form" form is closed, the data in the subform in datasheetview on the NAWInvoerForm is not yet refreshed. So I tried the following:

Code:
Private Sub Form_Close()
'------------------------------------------------------------
' RefreshNAWInvoerForm
'
'------------------------------------------------------------
On Error GoTo RefreshNAWInvoerForm_Err

    
    DoCmd.OpenForm "KlantNAW_InvoerForm", acNormal, "", "", , acNormal
    DoCmd.RunCommand acCmdRefresh

RefreshNAWInvoerForm_Exit:
    Exit Sub

RefreshNAWInvoerForm_Err:
    MsgBox Error$
    Resume RefreshNAWInvoerForm_Exit

End Sub

Which works just fine. After the form is closed, the name, adress and cases overview form is reopened and refreshed, thus the case that has just been created is shown nicely in the subform which is based on a query.

But it is starting to become bothersome, sometimes when I close the form in which I create a new case, I don't want to have the other form (NAWInvoerForm) reopening again.

So how can i make it so that when I close the form only the data in the "NAWInvoer_Form" is refreshed, without having to reopen the form again. I mean, in the background, the form is still open anyway. It just shouldn't keep popping up everytime.

It can't be hard, but I can't see it. I'm new at this. I have found some similar topics on this forum, but none which helps me out enough.

It should be something like:

On "thisandthatevent" do a "thisandthatcommand" on "thisandthatsubform" in "thisandthatform"

If I know how the syntax of that is done, it would help me out with some other problems I see coming in the near future. I've looked at, and tried some things based on this link: http://www.mvps.org/access/forms/frm0031.htm
But without success.

Can anyone help?
 
Another thing I tried just now:
Dim something As SubForm
Set something = Queries!CaseDateTimeInfoTable_Query_ForSubForm_KlantNAWInvoerForm
something.Requery

But then I get an "Object Required" error message when closing the form.
 
If the above example is supposed to work, how should I Dim the object?
 
To requery a subform, the syntax is:

Code:
Forms!YourMainFormNameHere.YourSubFormNameHere.Form.Requery

IMPORTANT: the part that says 'YourSubFormNameHere' is the name of the CONTROL that houses the subform on the main form. It is possible that the control name is the same as the subform, but it is also possible for it to be different, so the knowledge of differentiation between the subform and the subform control is important.
 
Ahhh..... tnx! I will try this this afternoon. :)

Thank you very much!

EDIT: Works like a charm! :)
 
Last edited:

Users who are viewing this thread

Back
Top Bottom