Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Over ride Error Message

Status
Not open for further replies.

vistor

Technical User
Dec 22, 2000
164
US
Hi,

Is there a way to over ride Access' automatic error message when a user types in a combo box that is set to Limit to List?

I want to create my own error message for the user
 
This is a sort of awkward method, and there may well be a better way, but here's what I've done in the past

1. Set "limit to list" (properties - data tab) to "No"
2. For the "on exit" event write code along the lines of...

If Me.cboBox.Value <> &quot;combo boxitem1&quot; And Me.cboBox.Value <> &quot;comboboxitem2&quot; Then
MsgBox &quot;friendly message here&quot;, vbOkOnly, &quot;field not searchable&quot;
End If

The &quot;If&quot; line goes through all items in the list. Works better for smaller combo boxes. If anyone else has an alternative, I'd love to hear it!

CJ
 
Thanks CJ, This works as you described, but I do want to limit the user to the list, only have my own message displayed. I will continue to research.
 
Sounds reasonable. It occurred to me that if you add the following line after the MsgBox it would always plunk the user rightback into the combo box (and keep doing it until they got it right)

Me.cboBox.SetFocus

best of luck however you decide to do it!
CJ
 
cdwd,
have a look at the onNotInList event. This fires when you have set the limit to list to false and the user enters something new.
The help file shows a way of asking if that value should be added to the list or not.

HTH
Ben ----------------------------------
Ben O'Hara
bo104@westyorkshire.pnn.police.uk
----------------------------------
 
Ben,

Thanks for your input but this does't work for what I want.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top