Fix Type Mismatch Using acFormDS in DoCmd.OpenForm in Microsoft Access
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.
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.
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.
In Microsoft Access, press Alt+F11 to open the Visual Basic Editor and select the module containing the DoCmd.OpenForm call.
Above the OpenForm call, add Dim myform As String and Dim frmview As AcFormView. Assign myform = "Customers" and frmview = acFormDS.
Call DoCmd.OpenForm myform, frmview so Access receives the acFormDS constant instead of the string "acFormDS".
Declare Each Variable with Its Own As Clause to Avoid Variant Types
Use this when multiple variables are declared on the same line and unexpected type behavior occurs.
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. 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. Install WPS Office: Run the downloaded installer and follow the on-screen instructions to complete installation.
- 3. Open your Office files: Launch WPS Office and open your existing .docx, .xlsx, or .pptx files to continue working without Access VBA configuration.

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.




