I'm having trouble building an update query in vba.
I need an Inner join between 2 tables where the joined field in the 2nd table is formatted by the function fncFormat. The table name and field name of the 2nd table are variables selected on the form that runs the query.
Here is my code:
The problem I'm having is including the fncFormat in the join. The following sql works without the fncFormat. (and the fncFormat function works everywhere else)
Any help would be appreciated!
Thanks,
Sup
I need an Inner join between 2 tables where the joined field in the 2nd table is formatted by the function fncFormat. The table name and field name of the 2nd table are variables selected on the form that runs the query.
Here is my code:
Code:
Dim strTbl2 as string
Dim strFld2 as string
Dim sql as string
strTbl = me.cboTbl
strFld = me.cboFld
sql = "UPDATE [" & strTlb2 & "] INNER JOIN Table1 "
sql = sql & "ON fncFormat([" & strTlb2 & "].[" & strFld2 & "]) = Table1.JoinFld "
sql = sql & "SET Table1.UpdateFld = True, Table1.Desc = 'New' "
sql = sql & "Where Table1.UpdateFld <> True;"
currentdb.execute(sql)
The problem I'm having is including the fncFormat in the join. The following sql works without the fncFormat. (and the fncFormat function works everywhere else)
Code:
sql = "UPDATE [" & strTlb2 & "] INNER JOIN Table1 ON [" & strTlb2 & "].[" & strFld2 & "] = Table1.JoinFld "
sql = sql & "SET Table1.UpdateFld = True, Table1.Desc = 'New' "
sql = sql & "Where Table1.UpdateFld <> True;"
currentdb.execute(sql)
Any help would be appreciated!
Thanks,
Sup