problem with query in VBA

  • Hi,

    I have a Access application which has following code.

    Set qry = CurrentDb.QueryDefs("qrySumOfExpenses")

    qry.Parameters("param1") = pubLocation

    Set rec = qry.OpenRecordset

    The above code is giving the error 3001: Invalid argument in the above query.

    But when I run the query manually in Access DB, it is running fine, I is asking for the parameter and once I entered the parameter, it showing the result well. But in code, it is showing the error.

    Thank You

  • venki (4/17/2009)


    Hi,

    I have a Access application which has following code.

    Set qry = CurrentDb.QueryDefs("qrySumOfExpenses")

    qry.Parameters("param1") = pubLocation

    Set rec = qry.OpenRecordset

    The above code is giving the error 3001: Invalid argument in the above query.

    But when I run the query manually in Access DB, it is running fine, I is asking for the parameter and once I entered the parameter, it showing the result well. But in code, it is showing the error.

    Hi,

    I am analyzed the problem and found the cause of problem.

    The above query intern calls another query qryExpDetailSum which has a User defined VBA function in HAVING clause. So when I call the query qrySumOfExpenses this intern calling the query qryExpDetailSum and this second query is again calling the user defined function. This UD function is returning a value and it is not catching that value and throwing the error as Invalid argument.

    Can you please give me any clues or suggestions for this to fix?

    Thank You

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply