Originally Posted by
adrian84
Hello Khalid,
Thanks for your posts! ... I was playing around with it some more and this is where I left off...
#
Private Sub Command104_Click()
Dim strSQL As String
strSQL = "INSERT INTO [NANW DCS preadsheet] ([d_DC], [d_SITE] )"
strSQL = strSQL + " SELECT [DC Info Spreadsheet].[d_DC], [DC Info Spreadsheet].[d_SITE] "
strSQL = strSQL + " WHERE [NANW DC Spreadsheet].[d_DC]= ')" & Me.[d_DC] & ""
DoCmd.SetWarnings False
DoCmd.RunSQL (strSQL)
DoCmd.SetWarnings True
End Sub
Hi,
Your code is okay, but there is a little missing I noted, you are missing ' after last &. It should be:
strSQL = strSQL + " WHERE [NANW DC Spreadsheet].[d_DC]= ')" & Me.[d_DC] & "'"
You got an error while not copying record to the "receiving table"; to get rid of it there is a solution:
Add the highlited lines to your code:
Code:
Private Sub Command104_Click()
On Error GoTo Err_Handler
Dim strSQL As String
strSQL = "INSERT INTO [NANW DCS preadsheet] ([d_DC], [d_SITE] )"
strSQL = strSQL + " SELECT [DC Info Spreadsheet].[d_DC], [DC Info Spreadsheet].[d_SITE] "
strSQL = strSQL + " WHERE [NANW DC Spreadsheet].[d_DC]= ')" & Me.[d_DC] & "'"
DoCmd.SetWarnings False
DoCmd.RunSQL (strSQL)
DoCmd.SetWarnings True
Err_Exit:
Exit Sub
Err_Handler:
MsgBox Err.Description
Resume Err_Exit
End Sub
Give a try