Others

Fix Type Mismatch Using acFormDS in DoCmd.OpenForm in Microsoft Access

Steve KSteve K Nov 13, 2026 869 views

Question details

The user needs to pass the acFormDS constant to the View parameter of DoCmd.OpenForm in Microsoft Access VBA without causing a type mismatch, and to declare the form name and view variables correctly.

Product
Microsoft Access
Device & OS
not provided
Scenario
Opening an Access form in Datasheet view from VBA by calling DoCmd.OpenForm with the acFormDS view argument.
Observed behavior
A type mismatch occurs when acFormDS is placed in quotation marks or when the view variable is declared as a String instead of AcFormView.
Before you start

Open the Visual Basic Editor in Microsoft Access and verify the exact form name used in the OpenForm call. Review the Dim statements for the form name and view variables before editing the code.

Solution 1Recommended

Use the AcFormView Enumeration and Remove Quotation Marks from acFormDS

Use this when DoCmd.OpenForm returns a type mismatch or when a form should open in Datasheet view reliably.

The View parameter of DoCmd.OpenForm expects an AcFormView enumeration value, not a string. The constant acFormDS represents Datasheet view and must be assigned without quotation marks.

1
Open the VBA module

In Microsoft Access, press Alt+F11 to open the Visual Basic Editor and select the module containing the DoCmd.OpenForm call.

2
Declare the form name and view variables

Above the OpenForm call, add Dim myform As String and Dim frmview As AcFormView. Assign myform = "Customers" and frmview = acFormDS.

3
Run the corrected OpenForm statement

Call DoCmd.OpenForm myform, frmview so Access receives the acFormDS constant instead of the string "acFormDS".

Form opens in Datasheet view: The type mismatch is resolved because the View argument is declared and assigned as an AcFormView enumeration value.
Free Microsoft Office alternative

Switch to WPS Office for Word, Excel, and PowerPoint Work Outside Microsoft Access

WPS Office is a free, lightweight Microsoft Office alternative with high compatibility for .docx, .xlsx, and .pptx files. It does not replace Access databases or VBA, but it provides a familiar ribbon interface and seamless document migration for everyday tasks.

  1. 1. Go to the WPS Office download page: Open the official WPS Office site and select the free download for Windows, macOS, Linux, Android, or iOS as needed.
  2. 2. Install WPS Office: Run the downloaded installer and follow the on-screen instructions to complete installation.
  3. 3. Open your Office files: Launch WPS Office and open your existing .docx, .xlsx, or .pptx files to continue working without Access VBA configuration.
Free, lightweight Office suite that avoids Microsoft Access VBA and database configurationOpens and edits Word, Excel, and PowerPoint file formats such as .docx, .xlsx, and .pptxFamiliar ribbon-style interface for a fast learning curve and seamless migrationBuilt-in PDF tools and cloud-ready workflows for everyday office tasks
microsoft office alternative - wps office

Frequently Asked Questions

What does the acFormDS constant do in Access VBA?

acFormDS is an Access constant from the AcFormView enumeration that tells DoCmd.OpenForm to open the form in Datasheet view. It must be used without quotation marks.

Why does DoCmd.OpenForm show a type mismatch when I use acFormDS?

The type mismatch usually occurs because acFormDS is passed as the string "acFormDS" or because the View variable is declared as String. Declare the variable as AcFormView and assign acFormDS without quotes.

How should I declare variables for the form name and view in DoCmd.OpenForm?

Use Dim myform As String and Dim frmview As AcFormView. Then assign the form name string to myform and the acFormDS constant to frmview before calling DoCmd.OpenForm.

Does Dim myform, frmview As String declare both variables as String?

No. In VBA, only frmview is declared as String; myform becomes a Variant. Declare each variable with its own As clause to avoid unexpected behavior.

Can WPS Office run Microsoft Access VBA or open Access databases?

WPS Office does not include an Access database or VBA replacement. It is a free alternative for Word, Excel, and PowerPoint files.