0

I have created a pass-through query that works fine on its own. I'm trying to connect my variable to a form that I've also created. Can my variable reference the data entered into the text box?

Here is my query. The variable I would like my form to connect to is the 'ACHTACHT' listed at the bottom of the query. I am passing through to a db2 as400 system.

SELECT T1.AZPCSP AS CUSTOMER_NUM, 
T2.AZCEEN AS GROUP,
T2.AZEFSD AS GROUP_START,
T2.AZEFED AS GROUP_END,
QWVAGN VA_NUMBER,
M7VAGD AS VA_DESCRIPTION, 
QWEFSD AS START,
QWEFED AS END,
T1.AZCEEN AS NID

FROM SCDBFP10.USCNAZL0 AS T1

LEFT JOIN SCDBFP10.USCNAZL0 AS T2
ON T1.AZPCSP = T2.AZPCSP
AND LEFT(TRIM(T2.AZCEEN),1) = 'E'
AND UCASE(RIGHT(TRIM(T2.AZCEEN),8)) = LCASE(RIGHT(TRIM(T2.AZCEEN),8))
AND T2.AZEFED > YEAR(NOW()) || RIGHT(CONCAT('0',MONTH(NOW())),2) || RIGHT(CONCAT('0', DAY(NOW())),2)

LEFT JOIN SCDBFP10. PMPZQWPF
ON T1.AZPCSP = QWCUNO
AND QWAGTY = 'ECOL'
AND QWEFED > YEAR(NOW()) || RIGHT(CONCAT('0',MONTH(NOW())),2) || RIGHT(CONCAT('0', DAY(NOW())),2)

LEFT JOIN SCDBFP10.PMVHM7PF

ON QWVAGN = M7VAGN

WHERE TRIM(T1.AZCEEN) = 'ACHTACHT'

My Form is called 'Ecolab' I've tried referencing the form using - Forms![Ecolab]![NID Text Box]

But the pass through can't reference the form.

Error message 'Token ! was not valid

June7
  • 19,874
  • 8
  • 24
  • 34
  • 2
    The only way is to get a reference of the query in VBA and use the `Replace()` function to replace the word in the query's `SQL` property. – Kostas K. Jan 18 '23 at 16:37

0 Answers0