I have a form with several subforms for entering information while surveying rooms in a building. I am trying to create a button to copy records from one of the subforms if the data is the same (for example if there are 3 types of flooring in multiple rooms) and append it into the same subform with a different space ID. I can not get it to recognize the Space ID on the current record. This is what I have in the command button code:
Private Sub AppendFloorCmd_Click()
Dim FloorTypes As String, SpaceUpdate As String
Dim CurrentSpace As TextBox
Set CurrentSpace = Me.SpaceID
FloorTypes = "INSERT INTO FlooringSurveyTable (FlooringHomoID)" & _
"SELECT FlooringSurveyTable.FlooringHomoID FROM FlooringSurveyTable " & _
"WHERE (((FlooringSurveyTable.SpaceID)=[Enter Space ID to copy]))"
DoCmd.SetWarnings False
DoCmd.RunSQL FloorTypes
SpaceUpdate = "UPDATE FlooringSurveyTable SET FlooringSurveyTable.SpaceID = CurrentSpace WHERE (((FlooringSurveyTable.SpaceID) Is Null))"
DoCmd.RunSQL SpaceUpdate
DoCmd.SetWarnings True
Me.Requery
End Sub
When I click the button, it appends the right records but makes me type in the current space ID - I've tried a bunch of ways of naming that control, but it will not work. Any help would be greatly appreciated.
Private Sub AppendFloorCmd_Click()
Dim FloorTypes As String, SpaceUpdate As String
Dim CurrentSpace As TextBox
Set CurrentSpace = Me.SpaceID
FloorTypes = "INSERT INTO FlooringSurveyTable (FlooringHomoID)" & _
"SELECT FlooringSurveyTable.FlooringHomoID FROM FlooringSurveyTable " & _
"WHERE (((FlooringSurveyTable.SpaceID)=[Enter Space ID to copy]))"
DoCmd.SetWarnings False
DoCmd.RunSQL FloorTypes
SpaceUpdate = "UPDATE FlooringSurveyTable SET FlooringSurveyTable.SpaceID = CurrentSpace WHERE (((FlooringSurveyTable.SpaceID) Is Null))"
DoCmd.RunSQL SpaceUpdate
DoCmd.SetWarnings True
Me.Requery
End Sub
When I click the button, it appends the right records but makes me type in the current space ID - I've tried a bunch of ways of naming that control, but it will not work. Any help would be greatly appreciated.