I'm in Windows XP with Access 2007. I have this code in my form's class module...
Expand|Select|Wrap|Line Numbers
- mySql = "INSERT INTO mtb_PartWordsSavedDetail ( PartWordsSavedHeadID, PartWords )"
- mySql = mySql & " SELECT CLng(" & Me!PartWordsSavedHeadID & ") AS [HeadID], mtb_PartWordsTemp.PartWordTemp"
- mySql = mySql & " FROM mtb_PartWordsTemp"
- mySql = mySql & " WHERE mtb_PartWordsTemp.PartWordsBox=" & PartBox & ";"
- Debug.Print mySql
- DoCmd.RunSQL mySql
Expand|Select|Wrap|Line Numbers
- INSERT INTO mtb_PartWordsSavedDetail ( PartWordsSavedHeadID, PartWords ) SELECT CLng(16) AS [HeadID], mtb_PartWordsTemp.PartWordTemp FROM mtb_PartWordsTemp WHERE mtb_PartWordsTemp.PartWordsBox=1;
I feel the problem has something to do with the [HeadID] getting converted into a string by the &'s. I tried using the CLng function to convert to a long integer. Again, the Sql updates the table correctly when I run it through a query, but it will not work in the module.
Can anyone help?
Thanks,
Adam