"Stapes" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> On 22 Mar, 20:31, "Douglas J. Steele"
> <NOSPAM_djsteele@NOSPAM_canada.com> wrote:
>> "Stapes" <steve.sta...@gmail.com> wrote in message
>>
>> news:(E-Mail Removed)...
>>
>> > On 22 Mar, 15:10, "Douglas J. Steele"
>> > <NOSPAM_djsteele@NOSPAM_canada.com> wrote:
>> >> Did you remember to set the combo box's LimitToList property to True?
>>
>> >> --
>> >> Doug Steele, Microsoft Access MVPhttp://I.Am/DougSteele
>> >> (no e-mails, please!)
>>
>> > Surely you mean set the LimitToList property to No? I have already
>> > done that.
>>
>> No, I meant True (Yes if you're doing it through the Properties window).
>>
>> The NotInList event doesn't fire unless you've told Access that you only
>> want to use values that are in the combo box.
>>
>> --
>> Doug Steele, Microsoft Access MVPhttp://I.Am/DougSteele
>> (no private e-mails, please)
>
> Hi Again
>
> OK. I set my LimitToList property to True. My NotInList event gets
> triggered & does what it's told - i.e. displays a message asking the
> user to input address details. But then, I get the message "The text
> you entered isn't an item in the list" and the focus has gone back to
> that field.
> If the item does not exist in the list - I want to create a new
> customer record.
What's the code you've got in your NotInList event?
Assuming that you've already got a customer creation form, your NotInList
event should prompt the user to ensure that they really do want to add a
record (in case it was just a typo) and then open the customer creation form
modally (i.e.: use the acDialog constant in conjunction with the OpenForm
method). The "trick" is to know when they've actually created a new customer
vs. when they've decided to cancel the creation process for some reason.
What I often do is create a property on the calling form (something like
"RecordAdded") and set it to False before calling the creation form. When I
call the creation form, I pass it the name of the form that's calling it. In
the Click event of the Close button on the creation form, I put logic that
determines whether or not the form was called from another form (i.e.: I
check the form's OpenArgs property) and update the RecordAdded property of
the calling form. In the calling form's NotInList event, I can then check to
see the value of RecordAdded., and set the value of Response appropriately.
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)