Hi,
When clicking a command button, I am trying to run VBA code to Insert the data from two fields on my form into two separate tables. I though I might have the code correct, but after I ran it, and checked the tables, the new records were not there. Here is my code, I hope someone can help. Thanks.
Private Sub cmd_Join_SAK_Insert_Click()
On Error GoTo Err_cmd_Join_SAK_Insert_Click
DoCmd.GoToRecord , , acNewRec
Exit_cmd_Join_SAK_Insert_Click:
Exit Sub
Err_cmd_Join_SAK_Insert_Click:
MsgBox Err.Description
Resume Exit_cmd_Join_SAK_Insert_Click
CurrentDb.Execute "INSERT INTO tbl_join_SAK ( [S-A ID], [Key Control ID] ) VALUES (" & [Forms]![frm_relationships_SAK]![ID] & "," & [Forms]![frm_relationships_SAK]![Key Control ID] & ");"
CurrentDb.Execute "INSERT INTO join_SAK2 ( [S-A ID], [Key Control ID] ) VALUES (" & [Forms]![frm_relationships_SAK]![ID] & "," & [Forms]![frm_relationships_SAK]![Key Control ID] & ");"
End Sub
When clicking a command button, I am trying to run VBA code to Insert the data from two fields on my form into two separate tables. I though I might have the code correct, but after I ran it, and checked the tables, the new records were not there. Here is my code, I hope someone can help. Thanks.
Private Sub cmd_Join_SAK_Insert_Click()
On Error GoTo Err_cmd_Join_SAK_Insert_Click
DoCmd.GoToRecord , , acNewRec
Exit_cmd_Join_SAK_Insert_Click:
Exit Sub
Err_cmd_Join_SAK_Insert_Click:
MsgBox Err.Description
Resume Exit_cmd_Join_SAK_Insert_Click
CurrentDb.Execute "INSERT INTO tbl_join_SAK ( [S-A ID], [Key Control ID] ) VALUES (" & [Forms]![frm_relationships_SAK]![ID] & "," & [Forms]![frm_relationships_SAK]![Key Control ID] & ");"
CurrentDb.Execute "INSERT INTO join_SAK2 ( [S-A ID], [Key Control ID] ) VALUES (" & [Forms]![frm_relationships_SAK]![ID] & "," & [Forms]![frm_relationships_SAK]![Key Control ID] & ");"
End Sub