?
Solved

Refresh Form when Closing a pop-up form

Posted on 2012-08-15
19
Medium Priority
?
508 Views
Last Modified: 2012-08-15
I'm in a pop-up form -  frmPatientCategories
When I close frmPatientCategories I want to refresh the main form I return to.  

Tried this:
Private Sub Form_GotFocus()
Me.Requery
Me.Refresh
End Sub

Doesn't work.  The focus doesn't come back to the main form when I close the pop-up form.  
Please suggest a fix.
0
Comment
Question by:Scotto123
  • 11
  • 8
19 Comments
 
LVL 61

Expert Comment

by:mbizup
ID: 38298586
If you use  acDialog as the window mode in the openform statement when opening the pop up window, I I think it's the sixth parameter, it will suspend the code execution in the main form and you can place the following line of code immediately after that statement:

Me.requery
0
 
LVL 61

Expert Comment

by:mbizup
ID: 38298592
If you use acdialog, the main form code suspends while the popup is open and resumes when the pop up is closed.
0
 

Author Comment

by:Scotto123
ID: 38298598
How do I do that Biz?  Where is that placed?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Scotto123
ID: 38298609
My form border type is Dialog.  Same thing?
0
 
LVL 61

Expert Comment

by:mbizup
ID: 38298614
Its right in the open form

Docmd.openform "frmname",,,,,acdialog

I'm not at a computer (cellphone) but it is either the fifth or sixth parameter
0
 
LVL 61

Expert Comment

by:mbizup
ID: 38298621
No... its not quite the same.  To suspend the code execution, acdialog needs to be right in the openform statement.
0
 

Author Comment

by:Scotto123
ID: 38298627
OK.  So I have this in my Open Form button to open the main menu.
DoCmd.OpenForm "WhiteBoard_Main", , , , , acDialog

Or does the acDialog need to be for the Pop-up??
0
 
LVL 61

Expert Comment

by:mbizup
ID: 38298636
An alternative syntax

Docmd.openform "frmname", wherecondition:= "your criteria ",  windowmode:= acdialog

With named parameters the order of arguments and number of commas doesnt matter.
0
 
LVL 61

Expert Comment

by:mbizup
ID: 38298639
It should be in the open form statement that opens your popup.
0
 

Author Comment

by:Scotto123
ID: 38298640
I want the main form to refresh when the popup form closes
0
 

Author Comment

by:Scotto123
ID: 38298647
acdialog on the popup form doesn't matter when it closes.  The main form is still not refreshing.
0
 

Author Comment

by:Scotto123
ID: 38298653
Here is the event to open the subform:
DoCmd.OpenForm "frmPatientCategories", WhereCondition:="[BoardID] = " & Me.BoardID, OpenArgs:=Me.BoardID & "|" & Me.PatientName, windowmode:=acDialog
0
 
LVL 61

Expert Comment

by:mbizup
ID: 38298654
Understood ... use the openform with acdialog as described and requery the mainform immediately after.

Docmd.openform "frmname",,,,, acdialog
Me.requery

Frmname is the popup.   The reqery will execute immediately after the popup is closed.
0
 
LVL 61

Expert Comment

by:mbizup
ID: 38298660
Missed your last post. Your syntax is good ... just place the requery immediately after that open form statement.
0
 

Author Comment

by:Scotto123
ID: 38298664
I'm sorry, I think I may have explained wrong.

There is  form open - main form.  I double click on a field and the popup opens with this command:
DoCmd.OpenForm "frmPatientCategories", WhereCondition:="[BoardID] = " & Me.BoardID, OpenArgs:=Me.BoardID & "|" & Me.PatientName, windowmode:=acDialog

Then I close the popup and the main form is still open and needs to be refreshed.
0
 
LVL 61

Accepted Solution

by:
mbizup earned 1600 total points
ID: 38298673
Right...

In the same click event on your main form immediately after that line of code you posted :

Me.requery
0
 
LVL 61

Expert Comment

by:mbizup
ID: 38298677
That will requery the mainform when the popup closes.
0
 

Author Closing Comment

by:Scotto123
ID: 38298692
You just blew my mind!  I wouldn't have figured that to work but it does!!

Thanks Biz!!
0
 
LVL 61

Expert Comment

by:mbizup
ID: 38298822
I had a hunch an element of disbelief was at work there ;-)  The way acdialog works came as a surprise to me too.

Glad to help out.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
When we develop an application in Ms Access 2016 we should also try to protect the queries, macros and table links. I know I may not have a permanent solution but for novice users, they will not manage to break your application. Below is the detail …
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Suggested Courses

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question