UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Adding Data to a Combo Box - when Not In List    
 
   
pere_de_chipstic...
post Jun 23 2008, 05:35 PM
Post #1

UtterAccess VIP
Posts: 7,585
From: South coast, England



The attached code samples show how to automatically add a new record to the table that forms the
Row Source of a combo box when the data typed into the combo box is ‘Not in the List’

There is a common code module that does the work and, apart from adding this code module to your DB, all
you have to do is add a single line of code to the ‘On Not in List’ event of each combo box where you want
to add new data.

CODE
    Response = AddNewToList(NewData, "TableName", "FieldName")


Where ‘TableName’ is the name of the combo box row source’s underlying table
And ‘FieldName’ is the name of the field in table ‘TableName’ you want to add the new record to.

Gord Hubbell suggested similar code that was originally presented in 2001 but was not carried through to UA.
Thanks also to both Walter Niesz and CyberCow who pointed out some improvements in my original submission.
In this latest version, improvements suggested by Alan_G and Doug Steele have been included. These cater for
field names with spaces (which you should avoid anyway!), and allow apostrophe’s to be included in the new data.

The attachment has versions for A2000, A2003 and A2007.



Edit: Text and attachments changed at request of Author.

Edited by: LPurvis on Thu Jul 24 6:06:02 EDT 2008.
Attached File(s)
Attached File  ComboNotInList V2.zip ( 59.16K ) Number of downloads: 462
 
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 21st May 2013 - 09:26 AM