Microsoft KB Archive/210461

= ACC2000: Assigned Values Not Displayed When Form Opened as Dialog =

Article ID: 210461

Article Last Modified on 6/24/2004

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q210461



Moderate: Requires basic macro, coding, and interoperability skills.



SYMPTOMS
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.



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. </li></ol>

Additional query words: prb

Keywords: kbprb kbusage KB210461

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.