Open a Form After an Append Query in Microsoft Access
Question details
Run an append query and then open a filtered form from a single button event without an Argument not optional error.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- A button should append records and then open a form for the current assessment session.
- Observed behavior
- The button needs a correctly constructed form-opening action after the append query; an incorrect argument can cause an error or prevent the form from opening.
Identify the saved append query, the destination form, and the AssessmentSessionID control on the form containing the button. Confirm that the destination form's record source contains AssessmentSessionID and that the current ID is available before the button runs.
Run the Append Query and Open the Form in a Button Event Procedure
Use VBA to run the saved append query first, then open the destination form filtered to the current numeric session ID.
The WhereCondition must be a string containing a field name, an operator, and the current value. The example assumes AssessmentSessionID is numeric and that the button's form has a control with that name.
Open the button's form in Design View, select the button, and open Property Sheet. On the Event tab, set On Click to [Event Procedure], then select the build button (...).
In the button's Click procedure, enter these lines, replacing qryAppendAssessment with your saved append query name and checking the destination form name: If IsNull(Me.[AssessmentSessionID]) Then MsgBox "Select an assessment session first." Exit Sub End If DoCmd.OpenQuery "qryAppendAssessment" DoCmd.OpenForm "frmAssessmentDetailforSubForm", WhereCondition:="[AssessmentSessionID] = " & Me.[AssessmentSessionID]
Save the form and VBA changes, switch to Form View, select a record with an assessment session ID, and click the button. Confirm that the append query completes and the destination form opens with the matching records.

Manage Assessment Lists in WPS Office
WPS Office is a free, lightweight alternative for working with spreadsheets and documents in a familiar interface. Open compatible Office files to move everyday document and list work more easily. WPS Office does not run Access databases, forms, or VBA procedures.

Frequently Asked Questions
Why does my OpenForm WhereCondition not filter the form?
The condition must be a string, such as "[AssessmentSessionID] = " & Me.[AssessmentSessionID] for a numeric ID. Check that the destination form's record source includes the field and that the current control has a value.
Do I need a macro to open the form after the append query?
No. Set the button's On Click property to [Event Procedure] and use DoCmd.OpenQuery followed by DoCmd.OpenForm in the Click procedure.
What should I check if the form opens without any records?
Check that the append query added records with the expected session ID, that the destination form's record source includes those records, and that the ID used in WhereCondition matches them.
Can I use the same condition for a text session ID?
Not unchanged. A text value must be enclosed in quotes in the WhereCondition, and any quote characters in the value must be escaped. Verify the field's data type in the table's Design View.




