How to Fix VBA CreateTableDef Error 3264 with a DSN-Less Access Link
Question details
The user is attempting to create a new linked SQL Server table using a DSN-less connection in VBA but encounters Error 3264.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- Creating a new linked SQL Server table via VBA code using the CreateTableDef method with a DSN-less connection string.
- Observed behavior
- Microsoft Access triggers Error 3264, 'No field defined; cannot append TableDef or Index,' because the VBA script fails to preserve the saved password attribute.
Verify that your SQL Server credentials are correct and that the database connection string is properly formatted in your VBA script before making modifications.
Pass the dbAttachSavePWD Attribute to CreateTableDef
Modify your VBA TableDef creation code to explicitly pass the dbAttachSavePWD attribute so Access correctly retains the required password information.
When VBA attempts to append a linked SQL Server table using a DSN-less connection, it requires authentication credentials to maintain the link. If the dbAttachSavePWD attribute is omitted, Microsoft Access does not preserve the password, which subsequently triggers Error 3264 when you try to append the TableDef object to the database.
In Microsoft Access, press ALT + F11 to launch the Visual Basic for Applications (VBA) editor.
Navigate to the specific module or subroutine where you define the DSN-less connection string and execute the CreateTableDef method.
Update the CreateTableDef call to include the dbAttachSavePWD constant. For example: Set td = CurrentDb.CreateTableDef(TableName, dbAttachSavePWD, SourceTableName, ConnectionString).
Ensure your code uses the Append method (e.g., CurrentDb.TableDefs.Append td) immediately after configuring the TableDef object to successfully link the new table.
Enhance Your Data Management with WPS Office
While Microsoft Access is widely used for specialized database operations, managing large datasets and complex macros can often be executed more efficiently using advanced spreadsheets. WPS Office offers a free, lightweight, and highly compatible alternative to Microsoft Office. It seamlessly supports VBA macros and provides intuitive data management tools without the heavy resource overhead.
- 1. Download and Install: Visit the official WPS Office website to download the free suite. Run the installation wizard to set it up on your device.
- 2. Open Your Datasets: Launch WPS Spreadsheet and open your existing .xlsx or .csv files to organize and structure your data seamlessly.
- 3. Run Custom VBA Macros: Use the built-in Developer tools to port and execute your existing VBA scripts for comprehensive data automation.

Frequently Asked Questions
What does Error 3264 mean in Microsoft Access VBA?
Error 3264, titled 'No field defined; cannot append TableDef or Index,' typically occurs when Access fails to append a new table definition. In the context of linked tables, this frequently happens when connection parameters, such as passwords, are not correctly saved during a DSN-less connection setup.
What is a DSN-less connection?
A DSN-less connection connects directly to a database server by hardcoding driver specifications, server names, and credentials directly into the connection string inside your code, bypassing the need to configure a local Data Source Name (DSN) via Windows ODBC tools.
Why is dbAttachSavePWD necessary when linking SQL Server tables?
When connecting to an external database like SQL Server without an active trusted connection, Access must explicitly store the credentials locally. Passing dbAttachSavePWD tells Access to cache the password with the linked table, preventing persistent authentication failures.
Can I run my database macros in WPS Office?
WPS Office does not include a direct Microsoft Access database clone. However, WPS Spreadsheet offers robust VBA and macro support, allowing you to run complex data manipulation and calculation scripts on standard spreadsheet formats with high compatibility.




