ACC95: Form and Report Questions and Answers (7.0)

ID: Q137345


The information in this article applies to:

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

SUMMARY

This article contains questions and answers about forms and reports in Microsoft Access for Windows 95 version 7.0.


MORE INFORMATION

  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.



Keywords          : kbdta 
Version           : 7.0
Platform          : WINDOWS 
Issue type        : kbinfo 

Last Reviewed: April 15, 1999