Microsoft KB Archive/142540

= ACC95: Yes/No Field Causes Error in AutoLookup Query =

Article ID: 142540

Article Last Modified on 11/17/2000

-

APPLIES TO


 * Microsoft Access 95 Standard Edition

-



This article was previously published under Q142540





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

When you add a record in a form (or query datasheet) bound to an AutoLookup query, you may receive one of the following error messages:

Current field must match join key '?' on 'one' side of one-to-many relationship because it has been updated.

-or

To make changes to this field, first save the record.



CAUSE
The AutoLookup query contains a Yes/No data type field from the "one" side table. For Yes/No fields, Microsoft Access automatically enters a 0 (zero) as the default value.

Because the Yes/No field is from the "one" side table and has a hidden default value, Microsoft Access assumes that you are trying to add a record to the "one" side as well as to the "many" side, which generates the error messages.



RESOLUTION
There are two possible workarounds for using a Yes/No field in an AutoLookup query. Your choice depends on whether you need to modify the Yes/No field in the "one" side table.

Method 1
If you want to add records to the "many" side table, but only display (not modify) the Yes/No field from the "one" side table, you can work around the hidden default value for Yes/No fields by using an expression in the query grid. For example, you can replace a Yes/No field reference such as   FieldName: MyYes/No with the expression:   FieldName: Expr1: [MyYes/No]+0 Because an expression is used to output the field instead of a direct reference, Microsoft Access does not try to set the value of the Yes/No field in the "one" side table when you add records to the AutoLookup query. A side-effect of this workaround is that you cannot modify the Yes/No field in the "one" side table.

Method 2
CAUTION: This method involves modifying the design of the "one" side table. If your application has multiple queries, forms, reports, and modules based on the table, this change may affect their behavior. To avoid potential side-effects caused by the design change, you should use Method 1 as the resolution for this issue.

If you need to modify the Yes/No field in the "one" side table and add records to the "many" side table, you can change the field's data type from Yes/No to Number. Then, you can set the field's FieldSize and Validation Rule properties to simulate the behavior of a Yes/No data type field. To do so, follow these steps:  Open your "one" side table in Design view. Select the Yes/No field that you included in your AutoLookup query.  Change the field's properties to the following settings:      Table: Sample ---     FieldName: SampleField DataType : Number FieldSize: Integer ValidationRule: 0 or -1  Close the table and save the design changes. If you receive a "Data integrity rules have changed" message, click Yes to test your existing data against the new validation rule.</li></ol>

NOTE: If you have an existing form that has a check box, option button, or toggle button for entering data into the Yes/No field, the form control should continue to work properly after you change the field's DataType, FieldSize, and ValidationRule properties as described in step 3.

<div class="status_section">

STATUS
Microsoft has confirmed this to be a problem in Microsoft Access 7.0. This problem no longer occurs in Microsoft Access 97.

<div class="moreinformation_section">

Steps to Reproduce Problem
<ol> Open the sample database Northwind.mdb.</li> Open the Order Details Extended query in Design view.</li> Add the Discontinued field from the Products table to the query grid.</li> Run the query.</li>  Enter the following values in a new record: <pre class="fixed_text">     OrderID: 11077 ProductName: Chai UnitPrice: $18.00 Note that you receive the error message in the "Symptoms" section. </li> Press the ESC key twice to undo the new record.</li></ol>

<div class="references_section">