I am currently working within Access 2013.
The problem that I have is that I am trying to duplicate a record from the main form to a subform with a button.
My tables consist of:
tbl40_1 tbl40_1_changes
ID (PK) ID (PK)
System_Name 40_1_ID (FK)
Configuration_Type System_Name
Configuration_ID Configuration_Type
Reference_Document Configuration_ID
Approval_Authority Reference_Document
Approval_Mechanism Approval_Authority
Item_Location Approval_Mechanism
Custodian Item_Location
Custodian
The current code that I have for the button consist of:
Private Sub Duplicate_Click()
Dim strInsert
Dim db As DAO.Database
StrInsert = "INSERT INTO tbl40_1_changes_subform (ID, [System_Name], [Configuration_Type], [Configuration_ID], [Reference_Document], [Approval_Authority], [Approval_Mechanism], [Item_Location], [Custodian]" & _
"SELECT ID, [System_Name], [Configuration_Type], [Configuration_ID], [Reference_Document], [Approval_Authority], [Approval_Mechanism], [Item_Location], [Custodian]" & _
"FROM frm40_1" & _
"WHERE [40_1_ID] = " & Me.tbl40_1_changes_subform.Form.txt40_1_ID
Set db = CurrentDb()
db.Execute strInsert, dbFailOnError
Set db = Nothing
End Sub
When I click on the button I am getting a Run-time error for [StrInsert = "INSERT INTO", "Select", "From", "Where"]. I am not for sure what is wrong within this code as it is highlighting this entire piece of code.