Switching off Warnings

Markvand

Registered User.
Local time
Today, 21:48
Joined
Jul 13, 2004
Messages
88
Hi,

I'm certain that this is a simple one, but I can't crack it

I have a combo box, and in the not on a list event I'm using:

DoCmd.SetWarnings False

MsgBox ("This value doesn't exist. Do you want to add it?"), vbOKCancel, "Warning!"

and somehow I'm still getting the warning: the entered text has to match the one on the list

Any help would be great.

Cheers

Mark
 
are you using this on the onNotInList event ? if yes try using response = acDataErrAdded instead of the setwarnings command.
 
Try this method...

The following code is from microsoft and It works like a charm.


Private Sub ComboBox_NotInList(NewData As String, Response As Integer)
' Add a new Name by typing a name in combo box.
Dim intNewFA As Integer, intTruncateName As Integer, strTitle As String, intMsgDialog As Integer

' Display message box asking if user wants to add a new category.
strTitle = "Name Not In List"
intMsgDialog = vbYesNo + vbQuestion + vbDefaultButton1
intNewFA = MsgBox("Do you want to add a new Name?", intMsgDialog, strTitle)

If intNewFA = vbYes Then
' Remove new name from Current Combo box so
' control can be requeried when user returns to form.
DoCmd.RunCommand acCmdUndo

' Display message box and adjust length of value entered in
' CategoryID combo box.
strTitle = "Name Too Long"
intMsgDialog = vbOKOnly + vbExclamation
If Len(NewData) > 50 Then
intTruncateName = MsgBox("Name can be no longer than " _
& "50 characters. The name you entered will be truncated.", _
intMsgDialog, strTitle)
NewData = left(NewData, 50)
End If

' Open frmfinancialadvisor form.
DoCmd.OpenForm "frmfinancialadvisor", acNormal, , , acAdd, acDialog, NewData
'Me.Visible = False
' Continue without displaying default error message.
Response = acDataErrAdded
End If

End Sub
 
thnks for fast replies guys,

Doran that should do me fine,

Cheers, mate

Mark
 
here is the sample database

attached is the sample database for "Not in the List".....


1. Click on Add order ( the first button)
2. On the order page, Try adding a new Value for Product.

Good Luck
Moe
 

Attachments

Thnks again for that, the first sample suits me better, though

I've put the code and it works, however I still get this annoying warning from Access: the value that you enter doesn't match to the one on the list.

No idea why
 

Users who are viewing this thread

Back
Top Bottom