A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Combo Box Not in List function



 
 
Thread Tools Display Modes
  #1  
Old November 27th, 2009, 03:23 AM posted to microsoft.public.access.queries
leo
external usenet poster
 
Posts: 236
Default Combo Box Not in List function

I have a combo box that lists the option (limited to list) from a table
called tblALLRECCS which has only one field called RECS. How do I write a
code in Not In List event of the combo box so that any new entries that is
not in the list will be added to the RECS in the tblALLRECCS, after prompting
the user with a message box whether he/she wants to add the new item (string)
?

Can some one help.

Thanks in advance
Leo
  #2  
Old November 27th, 2009, 05:41 AM posted to microsoft.public.access.queries
John_G via AccessMonster.com
external usenet poster
 
Posts: 23
Default Combo Box Not in List function

Hi -

This is from A2000 - I doubt it has changed much.

When you open the event procedure for the NotInList event, you will see that
there are two parameters: NewData as String, and Response as integer.

NewData contains the data the user entered, and Response indicates how it was
dealt with.

In your case after you prompted the user, for Yes you would add the new data
with SQL, something like this:

currentdb.execute "Insert into tblALLRECCS (Recs) Values ('" & newstring & "')
"
Response = acDataErrAdded

if the answer is "No", you might have:
me!comboboxname.Undo
Response=acdataerrcontinue

MS Access will automatically requery the combo box if you added a record.

The Help file explains this in more detail (look at the NotInList event), but
this will get you started.

John




Leo wrote:
I have a combo box that lists the option (limited to list) from a table
called tblALLRECCS which has only one field called RECS. How do I write a
code in Not In List event of the combo box so that any new entries that is
not in the list will be added to the RECS in the tblALLRECCS, after prompting
the user with a message box whether he/she wants to add the new item (string)
?

Can some one help.

Thanks in advance
Leo


--
John Goddard
E-Mail: jrgoddard AT cyberus DOT ca

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...eries/200911/1

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 01:22 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.