Fix #Error in Microsoft Access Expiration Date Queries
Question details
Replace #Error in calculated expiration date fields with either the effective date or a blank when an expiration period is empty.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- An Access query uses DateAdd to calculate expiration dates from EffectiveDate and the ActiveEnforcement or PostDisclosure year value.
- Observed behavior
- The calculated field displays #Error when ActiveEnforcement or PostDisclosure is blank.
Open the query in Design View and confirm that ActiveEnforcement and PostDisclosure are numeric year fields and EffectiveDate contains valid dates. Check that the field names match those used in your query.
Return the effective date when the year value is null
Use this approach when a missing expiration period should leave the effective date unchanged.
In the Access Navigation Pane, right-click the query and select Design View.
In the Field row of the ActiveEnforcement expiration column, enter: ActiveEnforcementExpires: IIf(IsNull([ActiveEnforcement]),[EffectiveDate],DateAdd('yyyy',Nz([ActiveEnforcement],0),[EffectiveDate]))
In the Field row of the PostDisclosure expiration column, enter: PostEnforcementExpires: IIf(IsNull([PostDisclosure]),[EffectiveDate],DateAdd('yyyy',Nz([PostDisclosure],0),[EffectiveDate]))
Select Run on the query design ribbon. Confirm that a null year value returns EffectiveDate and a populated value adds the specified number of years.

Return a blank when the year value is null
Use this approach when no expiration date should appear until a year value is supplied.
Work with exported Access data in WPS Spreadsheets
WPS Office is a free, lightweight Office alternative with a familiar interface. Export Access query results to an Excel workbook to review and work with them in WPS Spreadsheets; WPS does not fix Access query expressions.

Frequently Asked Questions
Why does a blank year field cause #Error in my Access query?
A blank numeric field may contain Null, which can cause a DateAdd calculation to fail. In Query Design View, use IsNull to choose a result and Nz to supply a safe numeric value to DateAdd.
How can I return the effective date instead of an error?
In the query's Field row, use IIf(IsNull([ActiveEnforcement]),[EffectiveDate],DateAdd('yyyy',Nz([ActiveEnforcement],0),[EffectiveDate])). This assumes EffectiveDate contains a valid date.
How do I display a blank instead of an expiration date?
In Design View, return Null in the IIf expression's true branch, for example: IIf(IsNull([ActiveEnforcement]),Null,DateAdd('yyyy',Nz([ActiveEnforcement],0),[EffectiveDate])).
What does 'yyyy' mean in DateAdd?
In DateAdd('yyyy', number, date), 'yyyy' specifies that the numeric value is added as years. For example, a value of 2 adds two years to EffectiveDate.
What should I check if the query still shows #Error?
In Query Design View, verify the field names and confirm that the year fields contain numeric values and EffectiveDate contains valid dates. IIf evaluates both branches, so an invalid DateAdd argument can still cause an error.




