ACC2000: Assigned Values Not Displayed When Form Opened as Dialog
ID: Q210461
|
The information in this article applies to:
SYMPTOMS
Moderate: Requires basic macro, coding, and interoperability skills.
When you use the OpenForm method or macro action to open a form
as a dialog form, fields on the form do not display the values
that you assign to them.
CAUSE
This occurs because dialog forms are modal, and Microsoft Access suspends
code execution until the dialog form is closed. After the form is closed,
you cannot set values for any of its controls.
MORE INFORMATION
Steps to Reproduce Behavior
The following example uses the OpenForm method in a Visual Basic procedure to reproduce the behavior. You get the same results if you use the OpenForm action in a macro.
- Open the sample database Northwind.mdb.
- Create a new form called Form1. Add a text box control to the form and set its Name property to Field0.
- Save and close the form.
- Create a module and type the following line in the Declarations section if it is not already there:
Option Explicit
- Type the following procedure:
Function TestModal()
DoCmd.OpenForm "Form1", acNormal, "", "", acFormEdit, acDialog
Forms!Form1!Field0 = "Hello"
End Function
- To test this function, type the following line in the Immediate window, and then press ENTER:
?TestModal()
Note that when the form opens, the text box does not display any text.
Also, when you close the form, you receive an error because the procedure continues to run, and the Field0 text box is no longer available to have its value set.
Additional query words:
prb
Keywords : kbusage kbdta FmsEvnt
Version : WINDOWS:2000
Platform : WINDOWS
Issue type : kbprb