• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 835
  • Last Modified:

Access 2010 runtime popup / form

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
peispud
Asked:
peispud
  • 2
1 Solution
 
mbizupCommented:
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
 
Dale FyeCommented:
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
 
peispudAuthor Commented:
Thank you.
0
 
Dale FyeCommented:
Glad to help.
0

Featured Post

Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now