?
Solved

Access 2010 runtime popup / form

Posted on 2012-03-28
4
Medium Priority
?
831 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 earned 2000 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
ID: 37791408
Glad to help.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

649 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