remove access message (1 Viewer)

mymy

Registered User.
Local time
Today, 16:43
Joined
Jun 18, 2001
Messages
16
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
 
D

DJN

Guest
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

Registered User.
Local time
Today, 16:43
Joined
Jun 18, 2001
Messages
16
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
 
M

mrabrams

Guest
Place this code after your dims:

DoCmd.SetWarnings False

Place this code after the End If:

DoCmd.SetWarnings True

HTH

mra
 

Fornatian

Dim Person
Local time
Today, 16:43
Joined
Sep 1, 2000
Messages
1,396
I think you should just be able to add this line after the msgbox

Response = acDataErrContinue
 

Users who are viewing this thread

Top Bottom