When I create an append Query in ms-access 2013 with parameters and any of those parameters' type is set to LongText
the query fails with error code 3001 Invalid Argument
. Changing the type to ShortText
however results in a working query. Both version are runnable by double clicking the query in access itself, but the first one fails when running it via following code:
Dim db As DAO.Database
Set db = CurrentDb
Dim qdf As QueryDef
Set qdf = db.QueryDefs("NeuerFachlicherInhalt")
qdf!Inhalt = inhalte("DefaultInhalt")
qdf!Formular = inhalte("Formular")
qdf.Execute
The table I insert the parameter to has a field type of LongText
and therefore I would expect this to work - what is the root cause of the issue here? And how can I pass in a long text if I am unable to specify a LongText
as parameter?
I think it might be connected to the length limitations of Strings in access. What exactly are those limitations? Google redirects you to concatenation and max length of string in VBA, access regarding the question for string lengths, but i can not find a definite answer to the length question(s):
ShortText
be?LongText
be?String
be?My queries in the two cases look like
PARAMETERS Inhalt LongText, Formular Short;
INSERT INTO FachlicherInhalt ( Inhalt, Formular )
SELECT [Inhalt] AS Expr1, [Formular] AS Expr2;
PARAMETERS Inhalt Text ( 255 ), Formular Short;
INSERT INTO FachlicherInhalt ( Inhalt, Formular )
SELECT [Inhalt] AS Expr1, [Formular] AS Expr2;
ShortText
(simply Text
prior to Access 2013) can be up to 255 characters in length.LongText
(Memo
prior to Access 2013) can be up to 1 GB in length, but most Access controls can only display 64000 characters. (A Textbox in a Form will start behaving weird when editing the text, if it contains much less than those 64000 characters.)See the Access 2013 Documentation for further details.
String
can be up to 2^31 charactersSee the Visual Basic for Applications Language Reference for further details.
Now for your question regarding the LongText-Parameter in the QueryDef-Object. Unfortunately DAO does not support LongText as Parameter-Type for a Query even though it lets you create the parameter in query design.
You have got the following options as a workaround:
inhalte("DefaultInhalt")
into the SQL of the query