Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / May 2007

Tip: Looking for answers? Try searching our database.

combobox question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
terry W - 21 Mar 2007 00:26 GMT
I am a new programmer with a question about comboboxes.  My combo has the
Limit To List property set to Yes.  When I enter a value not on the list, I
get the standard Access message, "The text you entered isn't an item... " .  
I'm trying to trap this error so I can use my own custom message, but no luck
yet.  How do I go about doing this?
swas - 21 Mar 2007 00:50 GMT
Terry,

Use the event 'On Not In List' in the properties for the combobox.

Set your code there to manage the situation.

Regards

swas

> I am a new programmer with a question about comboboxes.  My combo has the
> Limit To List property set to Yes.  When I enter a value not on the list, I
> get the standard Access message, "The text you entered isn't an item... " .  
> I'm trying to trap this error so I can use my own custom message, but no luck
> yet.  How do I go about doing this?
terry w - 21 Mar 2007 01:25 GMT
hi swas
Your suggestion to use the On NotInList allowed me to add my own error
message, but then the standard system message followed.  I tried to turn this
off with DoCmd.SetWarnings False, but no luck.  Any ideas?

> Terry,
>
[quoted text clipped - 11 lines]
> > I'm trying to trap this error so I can use my own custom message, but no luck
> > yet.  How do I go about doing this?
swas - 21 Mar 2007 02:14 GMT
Terry,

There would be a few ways, depending on how you want your form to interact
with the user.

If you just want to limit to list, then the Access error is probably
suitable alone.

If you want to have your own error, then you would need to leave the
combobox in a state that is suitable for Access to then accept. Examples
would be add the new value to the combobox After validating any other info),
or set the combobox to a blank "", or restore the combo.oldvalue which is the
previous value it was set to (combo = combo.oldvalue). Setting combo.undo
should have the same effect as the latter.

Unfortunately I am not a programmer, so sorry if this sounds vague... but
happy to help whare I can.

swas

> hi swas
> Your suggestion to use the On NotInList allowed me to add my own error
[quoted text clipped - 16 lines]
> > > I'm trying to trap this error so I can use my own custom message, but no luck
> > > yet.  How do I go about doing this?
terry w - 21 Mar 2007 02:49 GMT
very helpful suggestions.  Thanks
Marshall Barton - 21 Mar 2007 16:08 GMT
You need to decide what you want to do in that situation.

You might want to open another form (in dialog mode) to add
the item to the list, or, if the table is a simple list, add
the new value directly to the table, or you might want to
discard the offending value (Me.combo.Undo).

In all of those cases, you will want to set the NotInList
event procedure's Response argument to either
acDataErrorAdded or acDataErrorContinue.
Signature

Marsh
MVP [MS Access]

>Your suggestion to use the On NotInList allowed me to add my own error
>message, but then the standard system message followed.  I tried to turn this
[quoted text clipped - 9 lines]
>> > I'm trying to trap this error so I can use my own custom message, but no luck
>> > yet.  How do I go about doing this?
Harry - 03 May 2007 12:27 GMT
Hi Terry
You can put your own script in the event not in list. However after that you
must place cancel=true to avoid the regular standard access message.
I do use the following script myself;
begin code:
Private Sub ComboName_NotInList(NewData As String, Response As Integer)
   MsgBox "This value " & " ( " & NewData & " ) " & " is not within the
list." & vbCrLf & vbCrLf & _
          "Select a name from the list" & vbCrLf & _
           vbCrLf & _
          "Choose an other search function", vbInformation, "ComboSearch"
           Response = acDataErrContinue
           Me.ComboName = Null
           Cancel = True
end sub
end code
Good luck
Harry

> I am a new programmer with a question about comboboxes.  My combo has the
> Limit To List property set to Yes.  When I enter a value not on the list, I
> get the standard Access message, "The text you entered isn't an item... " .  
> I'm trying to trap this error so I can use my own custom message, but no luck
> yet.  How do I go about doing this?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.