error handling (1 Viewer)

legendv

Registered User.
Local time
Today, 18:19
Joined
Mar 18, 2002
Messages
99
Hello all,
I have a form and on that form there is a combo box that looks up values/records in my form. When the user clicks the pull down button on the combo box and selects a listing the form switches to the correct record. However the problem is... when the user types in a listing that isn't in the list then an error message appears. I don't want the error message to appear. If they choose/type a name in that isn't on the list I would like either my own error message to appear or to do nothing at all. Can anyone help?

TIA
Jon
 

ghudson

Registered User.
Local time
Today, 13:19
Joined
Jun 8, 2002
Messages
6,195
I suggest that you set the combo boxes "Limit To List" Data property to "Yes". The default is "No".

HTH
 

legendv

Registered User.
Local time
Today, 18:19
Joined
Mar 18, 2002
Messages
99
Limit to list - is set to Yes

The error message I receive says
Title: Microsoft Access
Body: The item entered is not in the list, choose an item in the....

I want to be able to change the "Title" i.e... remove the microsoft access part and put something humerous in. I want to be able to make up my own message box, which I assume would mean to have to suppress A2K's default msgbox, but I don't know how? Do you?
 

bradcccs

Registered User.
Local time
Tomorrow, 03:19
Joined
Aug 9, 2001
Messages
461
Add code to the "not in list" event

eg:

Response = acDataErrContinue
msgbox "Couldn't find " & NewData & ". Please retry"


Line1 continues past MS message
NewData refers to the entry made by the user.

You should probably clear the combo box after user message, or give the user the opportunity to add to the combo box.


HTH

Brad.
 

legendv

Registered User.
Local time
Today, 18:19
Joined
Mar 18, 2002
Messages
99
How can I get a user to "add to" the combo box, if the limit to list is set to yes?

P.S. Thanks for the other info!

Just tried your suggestion.... here's the code and the error

Private Sub Combo27_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[PtKey] = " & Str(Me![Combo27])
Me.Bookmark = rs.Bookmark
End Sub


Error = "Invalid Use Of Null"

How do I suppress the Null error?
 
Last edited:

legendv

Registered User.
Local time
Today, 18:19
Joined
Mar 18, 2002
Messages
99
Your first suggestion worked, except the title still says Microsoft Access. Is there anyway around changing the title to something else?
 

legendv

Registered User.
Local time
Today, 18:19
Joined
Mar 18, 2002
Messages
99
This took the title out:
MsgBox "Couldn't Find ", vbOKOnly, "Please Retry"

Didn't even think about it... sorry...

But now I get the "invalid use of null" any ideas on how to suppress it?
 

Users who are viewing this thread

Top Bottom