How can I refresh my table data?

P

Pamela

I have sfrmInspLoc based on tblInspLoc and apparently the table doesn't
update as fast as necessary to handle a popup form, pfrmInspLocRep, with the
OpenArgs property set to carry the InspLocID field across from sfrmInspLoc to
pfrmInspLocRep. The tblInspLoc has PK field InspLocID field and is
Autonumber. On the popup form it isn't key and is Integer. Right now, the
popup form opens, the ID field OpenArgs carries through and I can update the
popup, but when I try to close it, I get an error that the system can't find
the matching ID record in tblInspLoc. If I close out of sfrmInspLoc and
reopen, the popup works fine. Is there a way to have table update faster or
refresh before the AfterUpdate event of my combo? Thanks for any help!
 
J

John

I have sfrmInspLoc based on tblInspLoc and apparently the table doesn't
update as fast as necessary to handle a popup form, pfrmInspLocRep, with the
OpenArgs property set to carry the InspLocID field across from sfrmInspLoc to
pfrmInspLocRep. The tblInspLoc has PK field InspLocID field and is
Autonumber. On the popup form it isn't key and is Integer. Right now, the
popup form opens, the ID field OpenArgs carries through and I can update the
popup, but when I try to close it, I get an error that the system can't find
the matching ID record in tblInspLoc. If I close out of sfrmInspLoc and
reopen, the popup works fine. Is there a way to have table update faster or
refresh before the AfterUpdate event of my combo? Thanks for any help!

Search for refresh in the help file
 
P

Pamela

Unfortunately, I had already checked Microsoft help but was unable to find
the code procedure for refreshing. But for anyone else that may be
searching, by trial and error I found that adding the line: Me.Refresh to my
code, before the DoCmd.OpenForm line seemed to fix the problem. Thanks!
 
J

John W. Vinson

I have sfrmInspLoc based on tblInspLoc and apparently the table doesn't
update as fast as necessary to handle a popup form, pfrmInspLocRep, with the
OpenArgs property set to carry the InspLocID field across from sfrmInspLoc to
pfrmInspLocRep. The tblInspLoc has PK field InspLocID field and is
Autonumber. On the popup form it isn't key and is Integer. Right now, the
popup form opens, the ID field OpenArgs carries through and I can update the
popup, but when I try to close it, I get an error that the system can't find
the matching ID record in tblInspLoc. If I close out of sfrmInspLoc and
reopen, the popup works fine. Is there a way to have table update faster or
refresh before the AfterUpdate event of my combo? Thanks for any help!

What's probably happening is that the record is visible on the calling form
but has not yet been written into the table. Put a line in the code before you
open the popup form to explicitly save the record in the calling form. Either
of these will work:

DoCmd.RunCommand acCmdSaveRecord

or

If Me.Dirty Then Me.Dirty = False
 

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