473,668 Members | 2,759 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

NotInList problems

I am trying to allow the user to add an item to a list if it is not
found in a combobox. When the NotInList event is triggered I run a
function "AddItem" that has a custom dialog box to add an item to the
underlying table. The function either returns "Not Added", or the new
Items ID. I know the function works fine. Whe I try the code below I
get errors saying "Close action was cancelled" (referring to my custom
popup input box), & "The text you entered isn't an item in the list".
Then when I try to exit the form that has the combobox I get errors
saying "you must save the current field before you run the query
action" & the "you can not save this record at this time, do you still
want to exit" etc.
Does anybody see anything wrong with the code below?
Private Sub Item_NotInList( NewData As String, Response As Integer)
'create variable to hold function result
Dim AddStatus As String
AddStatus = AddItem

If AddStatus = "Not Added" Then
Response = acDataErrContin ue
Else:
Response = acDataErrAdded
End If

End Sub

Jan 11 '06 #1
7 6055
Bryan <br*********@ya hoo.com> wrote:
: I am trying to allow the user to add an item to a list if it is not
: found in a combobox. When the NotInList event is triggered I run a
: function "AddItem" that has a custom dialog box to add an item to the
: underlying table. The function either returns "Not Added", or the new
: Items ID. I know the function works fine. Whe I try the code below I
: get errors saying "Close action was cancelled" (referring to my custom
: popup input box), & "The text you entered isn't an item in the list".

It sounds like you haven't set the combobox's LimitToList
property to False.
--thelma
Jan 11 '06 #2
Thanks for your reply. The NotInList event can't even fire unless
LimitToList is set to yes. Any other thoughts?

Jan 11 '06 #3
Bryan <br*********@ya hoo.com> wrote:
: Thanks for your reply. The NotInList event can't even fire unless
: LimitToList is set to yes. Any other thoughts?

Sorry. I'm sleepy, probably too sleepy to be making much sense.
But I think that I remember trying to do such a thing and finding
that I couldn't circumvent the LimitToList restriction that way and
had to set it False and put the code that checked for valid
addition in the BeforeUpdate event
--thelma

Jan 11 '06 #4
After looking around on several forums I'm affraid that's what I'm
going to have to do. I have not found anybody who is able to use a
custom input box function to update a combobox when the NotInList event
is fired.

Jan 11 '06 #5
Bryan wrote:
I am trying to allow the user to add an item to a list if it is not
found in a combobox. When the NotInList event is triggered I run a
function "AddItem" that has a custom dialog box to add an item to the
underlying table. The function either returns "Not Added", or the new
Items ID. I know the function works fine. Whe I try the code below I
get errors saying "Close action was cancelled" (referring to my custom
popup input box), & "The text you entered isn't an item in the list".
Then when I try to exit the form that has the combobox I get errors
saying "you must save the current field before you run the query
action" & the "you can not save this record at this time, do you still
want to exit" etc.
Does anybody see anything wrong with the code below?
Private Sub Item_NotInList( NewData As String, Response As Integer)
'create variable to hold function result
Dim AddStatus As String
AddStatus = AddItem

If AddStatus = "Not Added" Then
Response = acDataErrContin ue
Else:
Response = acDataErrAdded
End If

End Sub


I googled Google Groups to find replies to NotInList questions I helped with a
long time ago. Here is the first one I found:

When I had problems with the NotInList event, I found three places that
really helped me understand what I was doing wrong:

1) http://www.mvps.org/access/forms/frm0015.htm
and

http://www.rogersaccesslibrary.com/T...ontents3.asp#N

which has these two pages:

2)
http://www.rogersaccesslibrary.com/d...Name=NotInList

3)
http://www.rogersaccesslibrary.com/d...Name=NotInList

As to your code, without seeing the function "additem" code, I don't know how
the item is being added to the table.

Maybe this will help; code from a previous post. You will have to change
field/table names......

Here is an alternate way to add to a combo box without
using an additional form. Change the control/field names
to your usage.

Set the LimitToList to YES.

In the NotInList Event: (Watch for line wrap...)

Private Sub Heading1_NotInL ist(NewData As String, Response As Integer)

'Cut/paste from here-----------------------
Dim db As DAO.Database
Dim rst As DAO.Recordset

' Prompt user to verify they wish to add new value.
' all one line
If MsgBox("Do you want to add '" & NewData & "' as a new
title?", vbYesNo) "Add New Item?") = vbYes Then

Set db = CurrentDb
Set rst = db.OpenRecordse t("tScopeOfWork HeaderList")
' the following adds the NewData to the table
With rst
.AddNew ' new record
!Header = NewData
.Update ' save it
End With
' close the recordset and cleanup
rst.Close
Set rst = Nothing
Set db = Nothing

' Continue without displaying default error message.
' This also does an automatic requery ******
Response = acDataErrAdded
Else
' don't add & continue
Response = acDataErrContin ue
' clear the combo box
Me.Heading1.Und o
End If
'To here-----------------------
End Sub


The reason you get the error messages when you try to exit the form with the
combo box on it is because you have started to add a new record - maybe a
required field is empty (null). I think if you press the <ESC> key a couple of
times, you should be able to close the form without the errrror <g> message.

(I just noticed I misspelled error after I posted this) :D
HTH
--
Steve S.
--------------------------------
"Veni, Vidi, Velcro"
(I came, I saw, I stuck around.)
Jan 11 '06 #6
The following code works for me in a database that manages vegetable
cooking. A combo box ' cboSelCookingTy peID' gets its data from a table
'ztblLookupCook ingType' which has two fields.

CookingTypeID autonumber
CookingType text

The code is as follows:-

Private Sub cboSelCookingTy peID_NotInList( NewData As String, Response
As Integer)
Dim strMsg As String
Dim rst As Recordset

strMsg = "'" & NewData & "' is not in the list of cooking types."
strMsg = strMsg & vbLf & vbLf
strMsg = strMsg & "Would you like to add it?"

If vbNo = MsgBox(strMsg, vbYesNo + vbQuestion, "New Cooking Type")
Then
Response = acDataErrDispla y
Else
Set rst = CurrentDb.OpenR ecordset("ztblL ookupCookingTyp e")
rst.AddNew
rst!CookingType = NewData
rst.Update
Response = acDataErrAdded
rst.Close
End If
End Sub

When the code runs on the 'Not in list' event it pops up a message box
that gives the user the option to add the new cooking type showing what
that is (this is useful because it deals with typos). If the user wants
to add the type it is added to the table.

Hope you can adapt this to fit your problem

Geoff G

Jan 11 '06 #7

It's what's happening in the AddItem function and any anciliary code we need
to see.

--

Terry Kreft
"Bryan" <br*********@ya hoo.com> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.com.. .
I am trying to allow the user to add an item to a list if it is not
found in a combobox. When the NotInList event is triggered I run a
function "AddItem" that has a custom dialog box to add an item to the
underlying table. The function either returns "Not Added", or the new
Items ID. I know the function works fine. Whe I try the code below I
get errors saying "Close action was cancelled" (referring to my custom
popup input box), & "The text you entered isn't an item in the list".
Then when I try to exit the form that has the combobox I get errors
saying "you must save the current field before you run the query
action" & the "you can not save this record at this time, do you still
want to exit" etc.
Does anybody see anything wrong with the code below?
Private Sub Item_NotInList( NewData As String, Response As Integer)
'create variable to hold function result
Dim AddStatus As String
AddStatus = AddItem

If AddStatus = "Not Added" Then
Response = acDataErrContin ue
Else:
Response = acDataErrAdded
End If

End Sub

Jan 11 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2804
by: Pieter Linden | last post by:
Just got done reading some of ADH2000 about comboboxes and the NotInList event... Doesn't look like it's possible to tweak the behavior of this so that I can have a non-text bound column, can I? Say I have a Customers--Invoices relationship, and I want to be able to pick the Customer's name from a combobox. (keeps people from entering the same text - or worse, just almost the same - a zillion times). So I create a CustomerID, enforce...
5
1673
by: David Deacon | last post by:
Hi i have the following code in a CustomerID field if the user enters a notinlist customer then they should dbl click to open the customer form However this error occurs "You tried to assign a null value to a varaible that is not a variant type" My code Dim lngCustomerID As Long If IsNull(Me!) Then
1
1727
by: Steve Leferve | last post by:
Can someone tell what what objects I have to work with on the 'NotInList' event? Basically I want to have a pop-up prompt the user if they want to add the data they typed into the database. Steve Lefevre
2
2218
by: whilstiwait | last post by:
I have a form containing a number of unbound combo boxes in three columns. Each column has boxes named "aaaa0", "aaaa1", etc. Using syntax like: With Forms(Me.Form.Name).Controls("txtTechnology" & i) .AfterUpdate = "=txtTechnology_Change(" & i & ")" .OnEnter = "=txtTechnology_OnEnter(" & i & ")" End With I can set events to a common routine for all the boxes, and in the
4
1805
by: CAD Fiend | last post by:
Hello, I have a combo box (cmbFirstName) on a form that is hitting a query (qryFirstName) and then putting that selected (or typed by user) value to the table field (name FirstName) on the table (tblUserInfo). The query hits a look up table called (lulFirstNames). If the user DOESN'T find the name they want in the combo box, they will just type it in.
11
2796
by: my-wings | last post by:
I think I've painted myself into a corner, and I'm hoping someone can help me out. I have a table of books (tblBooks), which includes a field (strPubName) for Publisher Name and another field (strPubCity) for Publisher City. These two fields have a many-to-one relationship with tables, (tlkpPubName and tlkpPubCity) respectively. The lookup tables only have one field (strPubName and strPubCity), which is their primary key. I also have...
3
1193
by: Bryan | last post by:
I have a listbox that the user is able to add items to through and SQL statement that is run on the NotInList event. At the end of the event, I set Response = acDataErrAdded, telling access that the NewData variable has been added to the underlying table. The recoord gets added to the underlying table just fine. The problem is, after the NotInList event, the afterupdate event is called by access. This is also no problem. But after...
1
1884
imrosie
by: imrosie | last post by:
Hello (from Rosie the newbie), I recently got help with a wonderful event to perform this from 'thescripts'...it recognizes that a name is not in the list an allows for (after parsing first and last name) for the addition of the new FullName into the Customer table. I've been working on some other forms in this application and hadn't noticed until now a little problem. The event occurs in a 'search customer' form. You first search an...
6
2677
by: Volker Neurath | last post by:
Hi all, I have a Problem with combobox-property "NotInList" and an unbound Form. The situation: On my main form i have three comboboxes for data-exchange (here: Names of distributor, reseller and final customers, the whole database is made for storing information about quotatations - no, not for quoting itself) ut the boxes actually may not contain all our distributors and reseller's
0
8462
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8381
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8893
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8797
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8583
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7401
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6209
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
2791
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1786
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.