aziz rasul
Active member
- Local time
- Today, 07:14
- Joined
- Jun 26, 2000
- Messages
- 1,935
I have the following snippet of code.
TableName = InputBox("Enter name of table", "Volume", "BTNI Private Circuit Summary June 2002")
DoCmd.CopyObject , TableName, acTable, "BTNI Private Circuit Summary Template"
sqlABTotal = "UPDATE [tblAB Total] INNER JOIN [" & TableName
sqlABTotal = sqlABTotal & "] ON [tblAB Total].[Rev Family A] = [" & TableName & "].[Rev Family] SET ["
sqlABTotal = sqlABTotal & TableName & "].[Total (adj PPC) - Rentals] = [tblAB Total]![Count AB]"
sqlABTotal = sqlABTotal & "WHERE ((([" & TableName & "].ID) Between 2 And 8));"
sqlABBTOU = "UPDATE [tblAB BTOU] INNER JOIN [" & TableName
sqlABBTOU = sqlABBTOU & "] ON [tblAB BTOU].[Rev Family A] = [" & TableName & "].[Rev Family] SET ["
sqlABBTOU = sqlABBTOU & TableName & "].[BT Own Use - Rentals] = [tblAB BTOU]![Count AB]"
sqlABBTOU = sqlABBTOU & "WHERE ((([" & TableName & "].ID) Between 2 And 8));"
DoCmd.RunSQL sqlABTotal
DoCmd.RunSQL sqlABBTOU
The SQL statement for sqlABTotal works, but the SQL statement for sqlABBTOU doesn't?
Both SQL statements are nearly identical, hence I can't see why the former works and the latter doesn't, i.e. it doesn't update the table. If I do the same thing using a query, then it's OK!!!!
Can anyone see what I'm doing wrong.
The reason for using SQL instead of a normal query, is that the table req'd in the query changes and hence I need to use RunSQL.
I'm not a SQL person, so go slowly on this one.
TableName = InputBox("Enter name of table", "Volume", "BTNI Private Circuit Summary June 2002")
DoCmd.CopyObject , TableName, acTable, "BTNI Private Circuit Summary Template"
sqlABTotal = "UPDATE [tblAB Total] INNER JOIN [" & TableName
sqlABTotal = sqlABTotal & "] ON [tblAB Total].[Rev Family A] = [" & TableName & "].[Rev Family] SET ["
sqlABTotal = sqlABTotal & TableName & "].[Total (adj PPC) - Rentals] = [tblAB Total]![Count AB]"
sqlABTotal = sqlABTotal & "WHERE ((([" & TableName & "].ID) Between 2 And 8));"
sqlABBTOU = "UPDATE [tblAB BTOU] INNER JOIN [" & TableName
sqlABBTOU = sqlABBTOU & "] ON [tblAB BTOU].[Rev Family A] = [" & TableName & "].[Rev Family] SET ["
sqlABBTOU = sqlABBTOU & TableName & "].[BT Own Use - Rentals] = [tblAB BTOU]![Count AB]"
sqlABBTOU = sqlABBTOU & "WHERE ((([" & TableName & "].ID) Between 2 And 8));"
DoCmd.RunSQL sqlABTotal
DoCmd.RunSQL sqlABBTOU
The SQL statement for sqlABTotal works, but the SQL statement for sqlABBTOU doesn't?
Both SQL statements are nearly identical, hence I can't see why the former works and the latter doesn't, i.e. it doesn't update the table. If I do the same thing using a query, then it's OK!!!!
Can anyone see what I'm doing wrong.
The reason for using SQL instead of a normal query, is that the table req'd in the query changes and hence I need to use RunSQL.
I'm not a SQL person, so go slowly on this one.