I have a popup form that has data entry input for the fields Trail_Code and Trail_Desc. The form has a “+” sign button to add the data to my continuous subform, which it does. The problem I’m having is that it only writes to one row of my subform. When I do another manual entry and click on the “+” button a second time, I want it to write to a new row in my subform, but it only overwrites the first row.
How can I get the popup form to write to my subform record row? I think there is a way to tell it to go to a new record and then write again to a different row, but I’m not sure how to do it. I think I have to save the INSERT record which I have SQL code for, but something is not right.
Below is my code that correctly writes it to my continuous subform but only one row, and overwrites the row when I write to it again. Please help.
'This vba write to the subform
Forms!f_Main!sfm_Trails!Trail_Code = sTrailCode
Forms!f_Main!sfm_Trails!Trail_Desc = sTrailDesc
Dim sSQL as string
Dim sTrailCode as string
Dim sTrailDesc as string
sSQL = “INSERT INTO Trail_Boxes”
sSQL = sSQL + “ ([Trail_Code], [Trail_Desc])”
sSQL = sSQL + “ VALUES (“ & sTrailCode & “, ‘” & sTrailDesc & “’) “
DoCmd.RunSQL sSQL
How can I get the popup form to write to my subform record row? I think there is a way to tell it to go to a new record and then write again to a different row, but I’m not sure how to do it. I think I have to save the INSERT record which I have SQL code for, but something is not right.
Below is my code that correctly writes it to my continuous subform but only one row, and overwrites the row when I write to it again. Please help.
'This vba write to the subform
Forms!f_Main!sfm_Trails!Trail_Code = sTrailCode
Forms!f_Main!sfm_Trails!Trail_Desc = sTrailDesc
Dim sSQL as string
Dim sTrailCode as string
Dim sTrailDesc as string
sSQL = “INSERT INTO Trail_Boxes”
sSQL = sSQL + “ ([Trail_Code], [Trail_Desc])”
sSQL = sSQL + “ VALUES (“ & sTrailCode & “, ‘” & sTrailDesc & “’) “
DoCmd.RunSQL sSQL