Solved

Access 2010 runtime popup / form

Posted on 2012-03-28
4
825 Views
Last Modified: 2012-03-31
Hi
I am using access 2010.

I am using a form to view / edit a table.  At runtime,  when the user clicks on a button, I would like to create a popup / form with a bound combobox.  The user would select a value in the combobox and then that value would be returned to the main form.

The name of the combobox would be                                            cmboName
This combobox would be bound to                                                 [Table Merchants].[Names]
Value would be returned to the main form in the variable        UserResponse

This is a formidable challenge for me.  I would appreciate any help that I can get.
0
Comment
Question by:peispud
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 61

Expert Comment

by:mbizup
ID: 37775890
Instead of using a variable for the return value, create a hidden unbound  textbox on the primary form for the user response.


Then in the AfterUpdate event of the combo box on your popup form:

Forms!MyMainFormName.txtMyHiddenTextBox = Me.cmboName
Then once the popup is closed, you can refer to the hidden textbox at any time with code on the primary form:

Me.txtMyHiddenTextBox
0
 
LVL 48

Accepted Solution

by:
Dale Fye (Access MVP) earned 500 total points
ID: 37776150
Another approach to accomplishing this is to open the popup form using the acDialog windowmode argument of the Openform method.  

    docmd.OpenForm "frmPopup", , , , ,acDialog

This pause all further processing of the code in the module that opens the form.  Then, instead of closing the popup, set it's visible property to False.  This will allow the remainder of the code in the calling module to continue, allowing you to pull the value from the popup form into your variable.  It would looks something like:

Private Sub yourbuttonname_Click

    docmd.OpenForm "frmPopup", , , , ,acDialog
    if currentproject.Allforms("frmPopup").isloaded = false then Exit Sub

    UserResponse = forms!frmPopup.cmboName
    docmd.close acform, "frmPopUp"

End Sub

This is a little longer than the process mentioned by mbizup, but has the benefit that it allows you to use this popup form for more than one main form, if you need to.  Whenever I use a popup like this, I generally have Cancel and Continue buttons on that form, if the user selects Cancel, I close the form. This causes the code above to exit the sub on the line after the OpenForm method, because the popup is no longer loaded.  If the user clicks Continue, I check to make sure a value has been entered in the combo, and if so, I hide the popup form (me.visible = false), which allows the rest of the code in the original button event to continue processing.

HTH
Dale
0
 

Author Closing Comment

by:peispud
ID: 37791405
Thank you.
0
 
LVL 48

Expert Comment

by:Dale Fye (Access MVP)
ID: 37791408
Glad to help.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

717 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