ACC2000: Unbound Controls on a Subform Are Blank When You Print the Main Form (265224)



The information in this article applies to:

  • Microsoft Access 2000

This article was previously published under Q265224
Moderate: Requires basic macro, coding, and interoperability skills.

This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).

SYMPTOMS

When you use code to set a value of an unbound control on a subform, the value is displayed in Form view and in Print Preview. However, when you print the main form, the unbound control on the subform is printed as a blank control, as though it had no value.

RESOLUTION

If the code that sets the value of the unbound control on the subform is relatively simple, you may be able to replace the code with a calculated expression. For example, you could replace rather simple code similar to the following
Private Sub Form_Current()
    Dim X As Integer
    X = Me!Field1 + Me!Field2 + Me!Field3
    Me![Unbound Control] = (X / 100) + .5
End Sub
				
with a calculated expression that is written directly within the ControlSource property of the unbound control as follows:
= ((Me!Field1 + Me!Field2 + Me!Field3) / 100) + .5
				
If the code is more complex, however, there may not be an immediate resolution to this problem.

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.

MORE INFORMATION

Steps to Reproduce the Behavior

CAUTION: If you follow the steps in this example, you modify the sample database Northwind.mdb. You may want to back up the Northwind.mdb file and follow these steps on a copy of the database.

  1. Start Microsoft Access 2000, and then open the sample database Northwind.mdb.
  2. Open the Product List form in Design view.
  3. Add an unbound text box to the detail section of this form, and then set the Name property of the text box to txtUnbound.
  4. Close the form, and when you are prompted to save changes, click Yes.
  5. Open the Categories form in Design view.
  6. Set the OnCurrent property of the Categories form to the following event procedure:
    Private Sub Form_Current()
       Forms!Categories![Product List].Form!txtUnbound = _
         Forms!Categories!CategoryName
    End Sub
    					
  7. View the form in Form view, and note that the category name on the main form also appears on the subform.
  8. Preview the form, and note that the category name still appears on the subform.
  9. Print the form, and note that category name no longer appears in the unbound text box.

Modification Type:MajorLast Reviewed:6/25/2004
Keywords:kbbug kbnofix kbprint KB265224