Forms Refreshing/Reloading

D

Dave

Access 2003

I have 2 related refreshing/reloading issues.

Issue 1: from a form containing a sub form a button opens a pop-up form for
adding data. When the pop-up form is closed the sub-form on the form
remaining open need to refresh to show the new record. If I hit the{f9} key
it does.

Issue 2: From a popup form I hit a button that opens another pop-up form. I
populate one field and close the form and I need a combo box on the first
popup to be populated with the new value. Again {f9} will do this.

I have tried

Me.Requery
Me.Reload
Me.Refresh
Sendkeys "{f9}"

And I have tried these on these events
On activate
Got focus
On load
On open

I am at a loss as to how to get this to happen

Any help will be appreciated

Dave
 
D

Dale_Fye via AccessMonster.com

Dave,

You really only have one issue. How do you return a value from a popup to
the form that popped it up. I've done this several ways:
1. You could setup the code in the popup form to save the current record and
use the value from that record in the main form when you close the popup form.
Assuming a command button for closing the popup:

Private sub cmd_PopUp_Close_Click
'This works best if the popup form only has one purpose.
'If it has more than one purpose, you might have to check to see
'which form to work on.
me.dirty = false
forms("frm_Main").cbo_SomeField.requery
forms("frm_Main").cbo_SomeField = me.ID
docmd.close acform, me.name
End sub

2. You could use the click event of the button on the main form to test to
see whether the popup is still loaded and visible. This method opens the
popup but doesn't use the acDialog parameter. Instead, it uses a loop to
check to see whether the popup has been hidden (done in the Click event of
the popups close button). It would look something like:

Private sub cmd_Popup_Click

docmd.openform "frm_PopUp"

Do While CurrentProject.Allforms("frm_PopUp").isloaded

if forms("frm_PopUp").visible = true then
DoEvents
else
me.cbo_SomeField.requery
me.cbo_SomeField = forms("frm_Popup").ID
docmd.close acform, "frm_Popup"
endif
Loop

End sub

This method is a little more resource intensive, as it is continously testing
to see whether the form is loaded and is visible, but it provide more
flexibility so that you can use the same pop-up from multiple places within
your project.
 

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