Hello everyone,
I am hoping you might be of some help. I want to copy the records from the previous week into the same table, but with a different weekly Id.
In my code I assigned the previous week to the "prevPlanID" and the current week to the "curWeeklyPlanID". Here is the SQL I used, but it's not working.
If anyone can figure out what I did wrong, please let me know.
Thanks
I am hoping you might be of some help. I want to copy the records from the previous week into the same table, but with a different weekly Id.
In my code I assigned the previous week to the "prevPlanID" and the current week to the "curWeeklyPlanID". Here is the SQL I used, but it's not working.
Code:
InsertSQL = "INSERT INTO tblFoodGroupsPerWeeklyPlan([FoodGroupIDFK], [Index], [WeeklyPlanIDFK], [IncludedInDiet]) " & _
"SELECT tblFoodGroupsPerWeeklyPlan.[FoodGroupIDFK], tblFoodGroupsPerWeeklyPlan.[Index], " & prevPlanID & " As tblFoodGroupsPerWeeklyPlan.[WeeklyPlanIDFK], tblFoodGroupsPerWeeklyPlan.[IncludedInDiet] " & _
"FROM tblFoodGroupsPerWeeklyPlan " & _
"WHERE tblFoodGroupsPerWeeklyPlan.WeeklyPlanIDFK = " & curWeeklyPlanID & ";"
If anyone can figure out what I did wrong, please let me know.
Thanks
Last edited: