getting rid of default error messages?

F

frank

In my table I do not allow duplicates for one of the
fields that is being imported (year). I want to give the
user the ability to select to add records with non-
duplicated years or add none of the records in the
attempted imported file.

so I've created this error trap to try to get rid of the
default error message that comes up when I try to import
data, but it shows up after the default error message. Can
anyone help?

BTW, (DoCmd.RunMacro "IMPORTorEXPORT.importData_EST") is
causing the error


Private Sub Command21_Click()
On Error GoTo ErrorTrap1

If Me.selectLog.Value = 1 Then
If MsgBox("Are you sure you want import Navy Log, OSHA
Log, and Est. Info data?", vbYesNo, "Confirm Delete") =
vbNo Then Exit Sub
DoCmd.RunMacro "IMPORTorEXPORT.importData_NAVY"
DoCmd.RunMacro "IMPORTorEXPORT.importData_OSHA"
DoCmd.RunMacro "IMPORTorEXPORT.importData_EST"
ElseIf Me.selectLog.Value = 2 Then
If MsgBox("Are you sure you want import OSHA Log data?",
vbYesNo, "Confirm Import") = vbNo Then Exit Sub
DoCmd.RunMacro "IMPORTorEXPORT.importData_OSHA"
ElseIf Me.selectLog.Value = 3 Then
If MsgBox("Are you sure you want import Est. Info
data?", vbYesNo, "Confirm Import") = vbNo Then Exit Sub
DoCmd.RunMacro "IMPORTorEXPORT.importData_EST"
ElseIf Me.selectLog.Value = 4 Then
If MsgBox("Are you sure you want import Navy Log data?",
vbYesNo, "Confirm Import") = vbNo Then Exit Sub
DoCmd.RunMacro "IMPORTorEXPORT.importData_NAVY"
End If

ErrorTrap1:
MsgBox ("Error")
Exit Sub

End Sub

Thanks,
Frank
 
N

Nikos Yannacopoulos

Frank,

You can use the following statement:

Docmd.SetWarnings False

before each action query command, together with a reversal of it:

Docmd.SetWarnings True

after the action query command, or you acn use just one of each at the
beginning and end of your procedure. This will suppress these warnings and
confirmation message boxes.

HTH,
Nikos
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top