D
Diana
Hello,
I am trying to turn off an error message '2051'.
I am appending data from excel to aceess to a table which
has a composite primary key. If an user tries to import
the same excel data twice Access gives an error because
of the potential dublicate key problems. I would like to
turn off the error message and I tried different
permutations of the procedure below and nothing is
working out right. Thank you for your time and help:
-----------------------------------------------
Private Sub cmdExport_Click()
Call macImport
End Sub
------------------------------------
Function macImport()
On Error GoTo macImport_Err
DoCmd.TransferSpreadsheet acImport,
8, "Tracking", "C:\Documents and
Settings\user\Desktop\PaperTracking.xls", True, "Export"
Beep
MsgBox "File Transfered.", vbInformation, ""
DoCmd.Close acForm, "Export"
DoCmd.OpenForm "Main", acNormal, "", "", , acNormal
DoCmd.SetWarnings True
macImport_Exit:
Exit Function
macImport_Err:
DoCmd.SetWarnings False
MsgBox "The records already exist in your table"
Resume macImport_Exit
End Function
I am trying to turn off an error message '2051'.
I am appending data from excel to aceess to a table which
has a composite primary key. If an user tries to import
the same excel data twice Access gives an error because
of the potential dublicate key problems. I would like to
turn off the error message and I tried different
permutations of the procedure below and nothing is
working out right. Thank you for your time and help:
-----------------------------------------------
Private Sub cmdExport_Click()
Call macImport
End Sub
------------------------------------
Function macImport()
On Error GoTo macImport_Err
DoCmd.TransferSpreadsheet acImport,
8, "Tracking", "C:\Documents and
Settings\user\Desktop\PaperTracking.xls", True, "Export"
Beep
MsgBox "File Transfered.", vbInformation, ""
DoCmd.Close acForm, "Export"
DoCmd.OpenForm "Main", acNormal, "", "", , acNormal
DoCmd.SetWarnings True
macImport_Exit:
Exit Function
macImport_Err:
DoCmd.SetWarnings False
MsgBox "The records already exist in your table"
Resume macImport_Exit
End Function