vbams-accessadodbrecordset

MS Access ADODB.Recordset Cannot Add adLongVarWChar field. Error 3001 Arguments are of Wrong Type


I am trying to add an adLongVarWChar field to an ADODB.Recordset in MS Access using the following sample code.

If I execute this sub, I get error 3001:

Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.

All other data types work Ok.

Has anyone else experienced this?

Public Sub Test()

    Dim rsADO As ADODB.Recordset
    Set rsADO = New ADODB.Recordset
    rsADO.CursorLocation = adUseClient

    rsADO.Fields.Append "Test", adLongVarWChar 

End Sub

Here is link to docs. https://learn.microsoft.com/en-us/sql/ado/reference/ado-api/append-method-ado?view=sql-server-ver16


Solution

  • You can avoid triggering that error by supplying something for DefinedSize, the third argument:

    rsADO.Fields.Append "Test", adLongVarWChar, -1