Operation in a sql in a macro
In the SQL tool this works OK insert into "Ledenarchief" ("archlidid","Naam") select "lidid" + 1000 ,"Naam" from "Leden" where "Datum ontslag" is not null or "datum overlijden" is not null When I want to do this in a macro (first time I do this), like
SQL = "INSERT INTO ""Ledenarchief"" " & _
"(""archlidid"" " & _
",""OKRAlidnr"" " & _
",""Naam"" " & _
") " & _
"SELECT" & _
" ""lidid"" "+1000" " & _
",""OKRAlidnr"" " & _
",""Naam"" " & _
"FROM ""Leden"" " & _
"WHERE ""Leden"".""Datum ontslag"" "is not null" "or" ""Leden"".""datum overlijden"" "is not null""
I get error BASIC syntax error. Unexpected symbol: ???. and the "+1000" is hightlighted. So I must have made a mistake somewhere, but I ddon't get it. Someone can help??
By "" "lidid" "" +1000 "" do you mean the name of a lidid1000 field or a calculated field?
In the first case I believe that "" lidid "" + cstr (1000) should be used, making sure that cstr (1000) does not start with a space that should therefore be removed with the right function (str, n).
But you would still write "" lidid1000 "" first
In the second case it seems to me that a calculated field must be written in the form (expression) as CalcFieldName. If you mean anything else you should explain it.
The error you get indicates that +1000 is interpreted either as a field name or as an unknown operator
The meaning is to add the value 1000 to the value of the lidid field (which is numeric, archlidid as well). Can you explain how to do this. I don't find a proper explanation by googling, maybe by not using the proper terminology.
try to replace " ""lidid"" "+1000" " with
" (""lidid"" + 1000) as ""fldNameYouWant"" "
That does away with this error, tx, but up to the next one: same error for "WHERE ""Leden"".""Datum ontslag"" "is not null", and the "null" gets highlighted.
try " WHERE ""Leden"".""Datum ontslag"" is not null or ""Leden"".""datum overlijden"" is not null " at the end of your sql string command query
That did it, tx a lot.