WX1232: Form and Report Questions and Answers (7.0)

Last reviewed: October 21, 1997
Article ID: Q137345
The information in this article applies to:
  • Microsoft Access version 7.0

Novice: Requires knowledge of the user interface on single-user computers.

The "Form and Report Questions and Answers" (WX1232) Application Note contains questions and answers about forms and reports in Microsoft Access for Windows 95 version 7.0.

You can obtain this Application Note from the following sources:

  • Microsoft FastTips Technical Library
  • Microsoft Technical Support

For complete information, see the "To Obtain This Application Note" section at the end of this article.

THE TEXT OF WX1232

  Microsoft(R) Product Support Services Application Note (Text File)
             WX1232: FORM AND REPORT QUESTIONS AND ANSWERS
                                                   Revision Date: 9/95
                                                      No Disk Included

The following information applies to Microsoft Access, version 7.0.

 INFORMATION PROVIDED IN THIS DOCUMENT AND ANY SOFTWARE THAT MAY
 ACCOMPANY THIS DOCUMENT (collectively referred to as an Application
 Note) IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
 EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
 WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
 PURPOSE. The user assumes the entire risk as to the accuracy and
 the use of this Application Note. This Application Note may be
 copied and distributed subject to the following conditions:  1) All
 text must be copied without modification and all pages must be
 included;  2) If software is included, all files on the disk(s)
 must be copied without modification (the MS-DOS(R)  utility
 diskcopy is appropriate for this purpose);  3) All components of
 this Application Note must be distributed together;  and  4) This
 Application Note may not be distributed for profit.

 Copyright (C) 1995 Microsoft Corporation.  All Rights Reserved.
 Microsoft, MS-DOS, and Windows are registered trademarks of
 Microsoft Corporation.
1. Q. I receive a "#Error?" message in a control when I run my form
      or report. What does it mean?

   A. This value means that Microsoft Access cannot evaluate an
      expression. The most common cause of this error is a circular
      reference. For example, a control with the following Name and
      ControlSource properties produces the error:

          Name: FirstName
          ControlSource: =[FirstName] & " " & [LastName]

      When Microsoft Access evaluates [FirstName] in the
      ControlSource property, it looks for a control by that name on
      the form. However, the control has just referenced itself. This
      is called a circular reference.

      To resolve the circular reference problem, change the Name
      property to FullName. Because there is no longer a control
      named FirstName, Microsoft Access looks for a field called
      FirstName when evaluating the expression set for the
      ControlSource property.

      For additional information about "#Error?" and other error
      values, order item number Q112103 by selecting the FastTips
      Technical Library option from the FastTips Main Menu.

2. Q. Why is every other page of my report blank, and how can I
      prevent these blank pages from being printed?

   A. Blank pages are printed when the total width of your report
      exceeds the width of the paper specified in the Page Setup
      dialog box. For example, blank pages are printed if your report
      form is 8 inches wide, the left and right margins are 1 inch
      wide (for a total width of 10 inches), but the paper size
      specified in the Print Setup dialog box is only 8.5 inches
      wide.

      With these print settings, if controls such as text boxes
      extend beyond 8.5 inches, the controls are printed on a second
      page. Otherwise, you receive a warning message stating that
      some pages may be blank. Blank pages generated after the
      warning are not counted in the total pages of your report.

      For additional information about preventing blank pages, order
      item number Q136459 by selecting the FastTips Technical Library
      option from the FastTips Main Menu.

3. Q. How do I cancel a report that does not contain any records?

   A. Microsoft Access for Windows 95 has a new report property
      called OnNoData. As its name implies, the macro or event
      procedure set for this property is triggered when a report
      without data is previewed or printed. For example, you can set
      the OnNoData property to a macro that contains two actions: a
      MsgBox action that tells the user there is no data and a
      CancelEvent action.

      For more information about canceling reports without data,
      search on the phrase "How do I cancel a report without records"
      then view "How Do I: Cancel the printing of a report when it
      doesn't contain any records" using the Answer Wizard from the
      Microsoft Access Help menu.

4. Q. How can I get my combo box or list box to default to the first
      item in the list?

   A. When you move to a new record on a form that has a combo box or
      a list box, the combo box is blank, or the list box does not
      have a value selected. The combo box or list box may have a
      table or query defined in its RowSource property that provides
      the list of items to be displayed in the box. Because the data
      in the underlying RowSource property varies with the addition
      or deletion of records, it is difficult to know what item will
      appear at the top of the list when the form is used. However,
      in Microsoft Access version 2.0 and later, you can use the
      ItemData method to cause a combo box or list box to default to
      any row. To cause the first row to be selected automatically,
      set the control's DefaultValue property to

          =[<MyCombo>].[ItemData](0)

      where <MyCombo> is the name of your control.

5. Q. How do I print a report for only the current record on the
      form?

   A. Use the Where argument of the OpenReport action to print a
      report for only the current record of a form. For example, if
      you have a form called MyForm and a primary key field named ID
      in both the form and the report, use the following expression
      in the Where argument:

          [ID]=Forms![MyForm]![ID]

      For more information about printing the current record, search
      on the phrase "How do I print a report for the current record
      on a form" then view "How Do I: Create a command button that
      prints the current record" using the Answer Wizard from the
      Microsoft Access Help menu.

6. Q. How can I check for duplicate records immediately after I enter
      a value in a primary key field?

   A. Typically, Microsoft Access does not check the values in
      primary key fields for duplicates until you move to the next
      record. If you want to check for duplicate values immediately
      after entering a value in a primary key field, use a macro in
      the field's BeforeUpdate property. The macro should use the
      DLookup() function to check for duplicates and then display an
      appropriate message.

      For an example of this macro, open the sample database
      Northwind.mdb, and open the Customers form in Design view. Note
      that the BeforeUpdate property of the CustomerID control is set
      to the Customer.ValidateID macro. To see the contents of the
      macro, click the Builder button next to the BeforeUpdate
      property.

      For additional information about using the DLookup() function,
      order item number Q136122 by selecting the FastTips Technical
      Library option from the FastTips Main Menu.

TO OBTAIN THIS APPLICATION NOTE

  • You can have this Application Note mailed or faxed to you from the automated Microsoft FastTips Technical Library, which you can call 24 hours a day, 7 days a week at (800) 936-4100. NOTE: The FastTips Technical Library is available only to customers within the U.S. and Canada.
  • If you are unable to access the source(s) listed above, you can have this Application Note mailed or faxed to you by calling Microsoft Technical Support Monday through Friday, 6:00 A.M. to 6:00 P.M. Pacific time at (425) 635-7050. If you are outside the United States, contact the Microsoft subsidiary for your area. To locate your subsidiary, please see the Microsoft World Wide Offices Web Site at:

          http://www.microsoft.com/worldwide/default.htm
    
Keywords          : Fstqa Softlib kbappnote kbfile kbfasttip
Version           : 7.0
Platform          : WINDOWS
Hardware          : x86
Issue type        : kbinfo


================================================================================


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: October 21, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.