Update Subform After Append Query

  • Thread starter Nick M via AccessMonster.com
  • Start date
N

Nick M via AccessMonster.com

I know this comes up a lot, but I’m still missing something…..
I have a button on a form that runs an append query to update a table.
There is subform that uses data from this table to create a list. When I
click the button the append query works fine, but I cannot get the subform
to refresh. I’ve tried all kinds of code from other postings but have had
no luck. Here is the code I have so far:

Private Sub update_main_Click()
On Error GoTo Err_update_main_Click

Dim stDocName As String
stDocName = "update_main_query"
DoCmd.SetWarnings False
DoCmd.OpenQuery stDocName, acNormal, acEdit
DoCmd.SetWarnings True


Exit_update_main_Click:
Exit Sub

Err_update_main_Click:
MsgBox Err.Description
Resume Exit_update_main_Click
DoCmd.SetWarnings True

End Sub

Any help would be appreciated.

Thanks,

Nick M
 
S

Steve Schapel

Nick,

Try it like this...

Private Sub update_main_Click()
On Error GoTo Err_update_main_Click

DoCmd.SetWarnings False
DoCmd.OpenQuery "update_main_query"
DoCmd.SetWarnings True
Me.NameOfSubform.Form.Requery

Exit_update_main_Click:
Exit Sub

Err_update_main_Click:
MsgBox Err.Description
Resume Exit_update_main_Click
DoCmd.SetWarnings True

End Sub
 
N

Nick M via AccessMonster.com

Thank you so much. I swear I tried that code, or a variation earlier with
no luck. You just saved me a lot of frusturation.

Thanks again,

Nick M
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top