Solved

Access 2010 runtime popup / form

Posted on 2012-03-28
4
816 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
  • 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 47

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 47

Expert Comment

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

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now