Main form returns to first record after subform edit

R

rivka.howley

I have a form with a subform. The subform has code that runs on the
AfterUpdate event. The code includes running several queries
(updating
data in the main form) and an hourglass cursor that turns on then
off.

When I edit a record on the subform, the main form flips back to the
first record. This does not occur when adding or deleting records on
the subform.


Any ideas why this is happening?
 
K

Keith Wilby

I have a form with a subform. The subform has code that runs on the
AfterUpdate event. The code includes running several queries
(updating
data in the main form) and an hourglass cursor that turns on then
off.

When I edit a record on the subform, the main form flips back to the
first record. This does not occur when adding or deleting records on
the subform.


Any ideas why this is happening?

Are you using the "requery" method? Try using "refresh" instead.

Keith.
www.keithwilby.com
 
R

rivka.howley

Are you using the "requery" method? Try using "refresh" instead.

Keith.www.keithwilby.com

I am not using either "requery" or "refresh." Here is the code for the
AfterUpdate event for the subform:

Private Sub Form_AfterUpdate()
Application.SetOption "confirm action queries", False
Dim db As DAO.Database

Set db = CurrentDb
'DoCmd.Hourglass True
If fTableExist("tbl_BASE_BYFM") Then
db.TableDefs.Delete "tbl_BASE_BYFM"
End If

Dim strDocName
strDocName = "qry_BASEPKTM"
DoCmd.OpenQuery strDocName, acNormal, acEdit

strDocName = "qry_BASE_BYFM"
DoCmd.OpenQuery strDocName, acNormal, acEdit

strDocName = "qry_UPDT_BASER"
DoCmd.OpenQuery strDocName, acNormal, acEdit

Application.SetOption "confirm action queries", True
'DoCmd.Hourglass False


End Sub

I tried adding me.refresh before the end sub line, and it still does
the same thing.
Thanks
 
K

Keith Wilby

Private Sub Form_AfterUpdate()
Application.SetOption "confirm action queries", False
Dim db As DAO.Database

Set db = CurrentDb
'DoCmd.Hourglass True
If fTableExist("tbl_BASE_BYFM") Then
db.TableDefs.Delete "tbl_BASE_BYFM"
End If

Dim strDocName
strDocName = "qry_BASEPKTM"
DoCmd.OpenQuery strDocName, acNormal, acEdit

strDocName = "qry_BASE_BYFM"
DoCmd.OpenQuery strDocName, acNormal, acEdit

strDocName = "qry_UPDT_BASER"
DoCmd.OpenQuery strDocName, acNormal, acEdit

Application.SetOption "confirm action queries", True
'DoCmd.Hourglass False


End Sub

What do all of those queries do?
 

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