View Full Version : remove access message


mymy
08-06-2001, 05:16 AM
HI all
I would like to display a message and remove the access one...How can I do that?
My code is like this

Private Sub Combo77_NotInList(NewData As String, Response As Integer)
docmd.beep
msgbox "you have to enter a valid number"
End Sub

What should I add to take off the access message?
Thanks in advance
Myriam

DJN
08-06-2001, 06:02 AM
I am assuming that you are trying to add a value to a table through a combobox and not validate the entry. If so the the following code will do it for you. Just remember to set the 'Limit to List' to yes.


Dim strMsg As String
Dim rst As Recordset
Dim db As Database

strMsg = "'" & NewData & "' is not in the list. " 'Or your own message here
strMsg = strMsg & "Would you like to add it?" 'and here
If MsgBox(strMsg, vbOKCancel, "YourFieldName") = vbOK Then

Set db = CurrentDb()
Set rst = db.OpenRecordset("YourTableName")
rst.AddNew
rst!YourFieldName = NewData

rst.Update
Response = acDataErrAdded


rst.Close

Else

Response = acDataErrContinue


End If

exit_cboComboBox_NotInList:

Exit Sub

err_cboComboBoxName_NotInList:

If Err = 2113 Then

Err = 0
Resume Next

Else

MsgBox str(Err)
MsgBox Err.Description
Resume exit_cboComboBoxName_NotInList

End If

mymy
08-06-2001, 06:04 AM
I want that the user enter a value that already exist..and it have to exist...if it doesn't exist..I want to put a message for the user that he/she has to enter a valid value...But the message of access always appear after mine...and I would like to take it off..
Thanks in advance
Myriam

mrabrams
08-06-2001, 07:17 AM
Place this code after your dims:

DoCmd.SetWarnings False

Place this code after the End If:

DoCmd.SetWarnings True

HTH

mra

Fornatian
08-06-2001, 08:53 AM
I think you should just be able to add this line after the msgbox

Response = acDataErrContinue