Share via

Invalid argument to function

Anonymous
2018-10-09T19:56:19+00:00

I am getting the above error on a query that use to work and I don't know why it stopped working. Here is the SQL as it is right now.

SELECT tblDSGLOBAL_DUPS.PLANT, tblDSGLOBAL_DUPS.IM_ITEM_NBR, qryUDF_BOM_Item.POSTP

FROM ((tblDSGLOBAL_DUPS LEFT JOIN tblFam_Code_U ON (tblDSGLOBAL_DUPS.PLANT = tblFam_Code_U.Plant) AND (tblDSGLOBAL_DUPS.IM_ITEM_NBR = tblFam_Code_U.AEXITM_ITEM_NBR)) LEFT JOIN qryE004_Err ON (tblDSGLOBAL_DUPS.PLANT = qryE004_Err.Planta) AND (tblDSGLOBAL_DUPS.IM_ITEM_NBR = qryE004_Err.[Item number])) LEFT JOIN qryUDF_BOM_Item ON (tblDSGLOBAL_DUPS.IM_ITEM_NBR = qryUDF_BOM_Item.YSOUKEY) AND (tblDSGLOBAL_DUPS.PLANT = qryUDF_BOM_Item.Plant)

WHERE (((tblDSGLOBAL_DUPS.ITEM_STATUS) Like "2") AND ((tblDSGLOBAL_DUPS.ITEM_TYPE) Not Like "3") AND ((tblDSGLOBAL_DUPS.MAKE_BUY_CODE) Like "1") AND ((qryE004_Err.[Error #]) Is Null) AND ((tblFam_Code_U.AEXITM_FAMLY_CODE) Is Null));

If I remove the qryUDF_BOM_Item from the query, everything works.

SELECT tblDSGLOBAL_DUPS.PLANT, tblDSGLOBAL_DUPS.IM_ITEM_NBR

FROM (tblDSGLOBAL_DUPS LEFT JOIN tblFam_Code_U ON (tblDSGLOBAL_DUPS.PLANT = tblFam_Code_U.Plant) AND (tblDSGLOBAL_DUPS.IM_ITEM_NBR = tblFam_Code_U.AEXITM_ITEM_NBR)) LEFT JOIN qryE004_Err ON (tblDSGLOBAL_DUPS.PLANT = qryE004_Err.Planta) AND (tblDSGLOBAL_DUPS.IM_ITEM_NBR = qryE004_Err.[Item number])

WHERE (((tblDSGLOBAL_DUPS.ITEM_STATUS) Like "2") AND ((tblDSGLOBAL_DUPS.ITEM_TYPE) Not Like "3") AND ((tblDSGLOBAL_DUPS.MAKE_BUY_CODE) Like "1") AND ((qryE004_Err.[Error #]) Is Null) AND ((tblFam_Code_U.AEXITM_FAMLY_CODE) Is Null));

If I leave the qryUDF_BOM_Item in and remove the Criteria filters from the tblDSGLOBAL_DUPS, again everything works.

SELECT tblDSGLOBAL_DUPS.PLANT, tblDSGLOBAL_DUPS.IM_ITEM_NBR, qryUDF_BOM_Item.POSTP

FROM ((tblDSGLOBAL_DUPS LEFT JOIN tblFam_Code_U ON (tblDSGLOBAL_DUPS.IM_ITEM_NBR = tblFam_Code_U.AEXITM_ITEM_NBR) AND (tblDSGLOBAL_DUPS.PLANT = tblFam_Code_U.Plant)) LEFT JOIN qryE004_Err ON (tblDSGLOBAL_DUPS.IM_ITEM_NBR = qryE004_Err.[Item number]) AND (tblDSGLOBAL_DUPS.PLANT = qryE004_Err.Planta)) LEFT JOIN qryUDF_BOM_Item ON (tblDSGLOBAL_DUPS.IM_ITEM_NBR = qryUDF_BOM_Item.YSOUKEY) AND (tblDSGLOBAL_DUPS.PLANT = qryUDF_BOM_Item.Plant)

WHERE (((qryE004_Err.[Error #]) Is Null) AND ((tblFam_Code_U.AEXITM_FAMLY_CODE) Is Null) AND ((qryUDF_BOM_Item.POSTP) Is Null));

But doing either of those, doesn't give me the results I need and as mentioned at the beginning, this query was working last week. All I did today was open the database and try to run the query. Nothing was changed.

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

ScottGem 68,830 Reputation points Volunteer Moderator
2018-10-09T21:01:08+00:00

The problem is probably not in that query, but rather in the queries being called. If a function no longer works it may be a references issue, So check for missing references.

Was this answer helpful?

2 people found this answer helpful.
0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Anonymous
    2018-10-22T15:54:26+00:00

    Not really sure what happened. All I did was delete the one query, re-create it with the exact same information, and it works fine now.

    Was this answer helpful?

    0 comments No comments