Hi. I have a form called Populate_Progression which uses a temporary table.
This is a datasheet with "Chapter_No", "Initial_Mapping_Completed" etc. When the user hit Apply it pushes the data to another table.
When the user populates the "Initial_Mapping_Completed" field for a particular "Chapter_No", and hit Apply, an SQL query updates all rows with that chapter number.
But they may populate "Initial_Mapping_Completed" in the main form underneath with a whole bunch of values, so they will see more rows for "Chapter_No". Attached is a screengrab. Chapter 19 has two different values, but the user can't change the value in this form because I can't figure out how to without using SQL, and even SQL updates all fields for that chapter no, not that row, as there are no unique ids in the temp table. At the moment they can only update Chapters 20 and 21, which have one value.
I've spent so long on this and almost want to give up. The SQL works fine for the chapters with one value. For the other scenario where a chapter_no has more than one value I tried
but the only updates the row that was selected in the main form.
Sorry if that was confusing. It is difficult to explain.
Here is the code for that event.
Thanks heaps
This is a datasheet with "Chapter_No", "Initial_Mapping_Completed" etc. When the user hit Apply it pushes the data to another table.
When the user populates the "Initial_Mapping_Completed" field for a particular "Chapter_No", and hit Apply, an SQL query updates all rows with that chapter number.
But they may populate "Initial_Mapping_Completed" in the main form underneath with a whole bunch of values, so they will see more rows for "Chapter_No". Attached is a screengrab. Chapter 19 has two different values, but the user can't change the value in this form because I can't figure out how to without using SQL, and even SQL updates all fields for that chapter no, not that row, as there are no unique ids in the temp table. At the moment they can only update Chapters 20 and 21, which have one value.
I've spent so long on this and almost want to give up. The SQL works fine for the chapters with one value. For the other scenario where a chapter_no has more than one value I tried
Code:
Forms!BM_Product.MapProgression_Subform.Form!INITIAL_MAPPING_COMPLETE = Me.Populate_Progression_Subform.Form.Init_Mapping_Complete
Forms!BM_Product.MapProgression_Subform.Requery
Sorry if that was confusing. It is difficult to explain.
Here is the code for that event.
Code:
If Me.Populate_Progression_Subform.Form.Init_Mapping_Complete.Enabled = True Then
Dim StrSQL_Init As String
CountValue_Init = DCount("INITIAL_MAPPING_COMPLETE", "Temp_Progression_Populate", "Chapter_No = '" & Me![Populate Progression Subform].Form!Chapter_No & "'")
If CountValue_Init = 1 Then
StrSQL_Init = "Update dbo_BM_Map inner Join Temp_Progression_Populate on dbo_BM_Map.Product_ID = Temp_Progression_Populate.Product_ID " _
& "Set dbo_BM_Map.Initial_Mapping_Complete = Temp_Progression_Populate.Initial_Mapping_Complete " _
& "Where dbo_BM_Map.Chapter_No = Temp_Progression_Populate.Chapter_No " _
& "And Temp_Progression_Populate.Chapter_No in (Select Temp_Progression_Populate.Chapter_No " _
& "from Temp_Progression_Populate " _
& "Group by Temp_Progression_Populate.Chapter_No " _
& "Having Count(Temp_Progression_Populate.Initial_Mapping_Complete) = 1)"
DoCmd****nSQL (StrSQL_Init)
End If
If CountValue_Init > 1 Then
Forms!BM_Product.MapProgression_Subform.Form!INITIAL_MAPPING_COMPLETE = Me.Populate_Progression_Subform.Form.Init_Mapping_Complete
Forms!BM_Product.MapProgression_Subform.Requery
End If
End If
Thanks heaps