Access 2007 Setting a field to choose from in a dialog
I would like to set a field to a value selected from a grid in a dialog. I am using Access 2007.
In WinForms, I would:
- Create a child form
- create data grid
- add property for selected item
- In parent form
- add a button to open the form
- as a result of a successful dialog, we will get the selected element from the property
- update object
- persist in event
- In the parent board
- set selected value in child grid
Is this possible in Access 2007 forms? I have multiple items with children. Can I select it and return it to the parent? On the other hand, can I select the selected item by default when editing?
How do people approach this in Access?
+2
source to share
1 answer
Here's a template that works as long as the child form is modal.
In your parent form
Private Sub cmdOpenChild_Click()
DoCmd.OpenForm "ChildDialog", acNormal, , , , acDialog, "Info for child"
'This line will block further code execution until child form is hidden or closed.
MsgBox Forms.Item("ChildDialog").Controls.Item("SomePropertyOrControl").Value
DoCmd.Close acForm, "ChildDialog"
end sub
The child form has a close button which actually only hides the form.
Private Sub cmdClose_Click()
'hide the form instead of closing it to return control to caller.
Me.Visible = False
End sub
+1
source to share