Syntax for a Function called in an Update Query and how to insert the desired task in the function.

tovia schlesinger 241 Reputation points
2020-12-31T17:13:42.29+00:00

In the middle of an Update Query, I want to run a function that should return a value depending on the task. The task performed is the date field of this row.

The Function Name is "BeforeDate"

StringSQL= "Update Table SET Table .Period = " & BeforeDate("Table.[Date]")

If I write the above code to return the desired value, I get the following error message:

"System.InvalidCastException: 'Conversion from string "Table.[Date]" to type 'Date' is not valid.'"

What is the proper syntax to accomplish the above?

Developer technologies Visual Studio Other
{count} votes

Accepted answer
  1. tovia schlesinger 241 Reputation points
    2020-12-31T21:42:09.887+00:00

    Now I Change it
    for 3 update Query's
    Without the function

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. tovia schlesinger 241 Reputation points
    2020-12-31T18:55:53.267+00:00

    now I changed the Quary Like this
    StringSQL = "Update Table SET Table.Period = {BeforeDate(Table.[Date])}"
    StringSQL &= " WHERE (((Table.[Date]) < #{BeforeDate(Table.[Date])}#) "

    I Added { }

    And i got a error

    System.Data.OleDb.OleDbException: 'Malformed GUID. in query expression '{BeforeDate(Table.[Date])}'.'

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.