Suppress Not In List Warning

G

Guest

Does anyone know how to suppress the NotInList warning that appears after the
notinlist event is activated? I've tried both error handling and setwarning
false. Niether seem to work. Here is my code:

Private Sub Customer_NotInList(NewData As String, Response As Integer)
On Error GoTo Err_Customer_NotInList

Dim CustText As String

DoCmd.SetWarnings False
If MsgBox("The Customer you have entered is not in the system. Would you
like to add them?", vbYesNo) = vbYes Then
CustText = Forms!newJobentry!Customer.Text
Me.Undo
DoCmd.OpenForm "addCustomer", , , , acFormAdd
Forms!Addcustomer![Customer] = CustText
Else
Me.Undo
End If
DoCmd.SetWarnings True

Exit_Customer_NotInList:
Exit Sub

Err_Customer_NotInList:

Resume Exit_Customer_NotInList

End Sub

Thanks for any help

Rico
 
B

Brendan Reynolds

Set the Response argument to one of acDataErrAdded, if the new data has been
added, or acDataErrContinue, if it has not.

The third, default value for the Response argument, is acDataErrDisplay,
which displays the default error message.
 
G

Guest

Thanks Brendan,

The acDataErrContinue bit worked but the acDataErrAdded did not. I've not
used these functions before and probably using them incorrectly. Please could
you advise. Here is my code now:

Private Sub Customer_NotInList(NewData As String, Response As Integer)
On Error GoTo Err_Customer_NotInList

Dim CustText As String

DoCmd.SetWarnings False
If MsgBox("The Customer you have entered is not in the system. Would you
like to add them?", vbYesNo) = vbYes Then
CustText = Forms!newJobentry!Customer.Text
Me.Undo
DoCmd.OpenForm "addCustomer", , , , acFormAdd
Forms!Addcustomer![Customer] = CustText
Response = acDataErrAdded
Else
Me.Undo
Response = acDataErrContinue
End If
DoCmd.SetWarnings True

Exit_Customer_NotInList:
Exit Sub

Err_Customer_NotInList:

Resume Exit_Customer_NotInList

End Sub

Brendan Reynolds said:
Set the Response argument to one of acDataErrAdded, if the new data has been
added, or acDataErrContinue, if it has not.

The third, default value for the Response argument, is acDataErrDisplay,
which displays the default error message.

--
Brendan Reynolds


rico said:
Does anyone know how to suppress the NotInList warning that appears after
the
notinlist event is activated? I've tried both error handling and
setwarning
false. Niether seem to work. Here is my code:

Private Sub Customer_NotInList(NewData As String, Response As Integer)
On Error GoTo Err_Customer_NotInList

Dim CustText As String

DoCmd.SetWarnings False
If MsgBox("The Customer you have entered is not in the system. Would
you
like to add them?", vbYesNo) = vbYes Then
CustText = Forms!newJobentry!Customer.Text
Me.Undo
DoCmd.OpenForm "addCustomer", , , , acFormAdd
Forms!Addcustomer![Customer] = CustText
Else
Me.Undo
End If
DoCmd.SetWarnings True

Exit_Customer_NotInList:
Exit Sub

Err_Customer_NotInList:

Resume Exit_Customer_NotInList

End Sub

Thanks for any help

Rico
 
B

Brendan Reynolds

You'll need to use the acDialog argument when opening the 'addCustomer'
form, otherwise the code will not wait until the form is closed before
executing the Response = acDataErrAdded line.

--
Brendan Reynolds


rico said:
Thanks Brendan,

The acDataErrContinue bit worked but the acDataErrAdded did not. I've not
used these functions before and probably using them incorrectly. Please
could
you advise. Here is my code now:

Private Sub Customer_NotInList(NewData As String, Response As Integer)
On Error GoTo Err_Customer_NotInList

Dim CustText As String

DoCmd.SetWarnings False
If MsgBox("The Customer you have entered is not in the system. Would
you
like to add them?", vbYesNo) = vbYes Then
CustText = Forms!newJobentry!Customer.Text
Me.Undo
DoCmd.OpenForm "addCustomer", , , , acFormAdd
Forms!Addcustomer![Customer] = CustText
Response = acDataErrAdded
Else
Me.Undo
Response = acDataErrContinue
End If
DoCmd.SetWarnings True

Exit_Customer_NotInList:
Exit Sub

Err_Customer_NotInList:

Resume Exit_Customer_NotInList

End Sub

Brendan Reynolds said:
Set the Response argument to one of acDataErrAdded, if the new data has
been
added, or acDataErrContinue, if it has not.

The third, default value for the Response argument, is acDataErrDisplay,
which displays the default error message.

--
Brendan Reynolds


rico said:
Does anyone know how to suppress the NotInList warning that appears
after
the
notinlist event is activated? I've tried both error handling and
setwarning
false. Niether seem to work. Here is my code:

Private Sub Customer_NotInList(NewData As String, Response As Integer)
On Error GoTo Err_Customer_NotInList

Dim CustText As String

DoCmd.SetWarnings False
If MsgBox("The Customer you have entered is not in the system. Would
you
like to add them?", vbYesNo) = vbYes Then
CustText = Forms!newJobentry!Customer.Text
Me.Undo
DoCmd.OpenForm "addCustomer", , , , acFormAdd
Forms!Addcustomer![Customer] = CustText
Else
Me.Undo
End If
DoCmd.SetWarnings True

Exit_Customer_NotInList:
Exit Sub

Err_Customer_NotInList:

Resume Exit_Customer_NotInList

End Sub

Thanks for any help

Rico
 

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

Similar Threads


Top