SomeDude
SomeDude

Reputation: 23

Cannot close and reopen Form in Access (OLE Connetion)

I'm a VBA noob but maybe you can help:

I want to refresh all Forms (subforms) and queries on my Main Form "FinalForm". However I use Access as a frontend to SQL server. So apparently the usual buttons (created with the wizard, like refreh, new record etc.) won't work.

I created a (stupid) workaround by closing and reopening the form:

Private Sub Befehl71_Click()
    DoCmd.Close acForm, "FinalForm"
    DoCmd.OpenForm FormName:="FinalForm"
End Sub

This works fine within the vba editor but fails if triggered by button (something about an ole communication error).

How can I fix this ?

Upvotes: 1

Views: 1030

Answers (1)

asdev
asdev

Reputation: 943

The standard VBA procedure is

Me.Requery

For a subform only

Me.PUT_SUBFORM_NAME_HERE.Form.Requery

Upvotes: 1

Related Questions