Hi everyone!
I've been stuck on this query for hours and I probably only need a couple lines of code to solve the problem. I'm trying update the values in one of the columns of a permanent table (tblGrossReciepts) from a temporary table (tblImportTable). There will be more temporary tables in the future that will be used to update the permanent table. I will also write a couple of other queries that are similar to this once I get it working. The query written below works fine if I hard code the column name, but I need the column name to be automatically inserted so that the user won't have to do it manually.
UPDATE tblGrossReciepts INNER JOIN tblImportTable ON tblGrossReciepts.[Licence Id] = tblImportTable.[Licence ID]
SET tblGrossReciepts.[columnName] = [tblImportTable].[Gross Receipts]
WHERE (((tblImportTable.[Licence Id]) Is Not Null) AND ((tblGrossReciepts.[Licence Id]) Is Not Null));
I've already set up a separate query that will return only the name of the needed column, but I don't know how to replace the hard coded [columnName] with the result of the query. Is there a way to run a sub query in the SET statement to do this? Or, if not, is there a way to use VBA to insert the column name?
I'd really appreciate your help. Thanks!