PC Review


Reply
Thread Tools Rate Thread

Add to Combo box

 
 
The Joker via AccessMonster.com
Guest
Posts: n/a
 
      31st Mar 2006
Hello All,
I am working on a pretty basic "add to combo box" function. What I am
looking for is the user to have the option if they would like to add the new
information to the combo box. If they do it gets added (which works fine),
If they choose no I want them still to be able to submit the information in
the form but just not have it added to the combo box. How I currently have
it they have to add it or they can't use it, I get the "The text you entered
isn't in the list" error because I have set Limit to List "Yes". Technically
I don't want to limit to list. Any help will be greatly appreciated. Thanks.


Here is my code:

Private Sub Combo237_NotInList(NewData As String, Response As Integer)
' this is the combo box for prepayment penaltys "add to combo" feature

DoCmd.SetWarnings (False)

Dim strSql As String
If MsgBox(NewData & " is not in list, would you like to add it?", _
vbYesNo + vbQuestion) = vbYes Then
strSql = "insert into tbl_GSPrepaypen (Prepayment) values('" & NewData &
"')"
CurrentDb.Execute strSql
Response = acDataErrAdded

End If
DoCmd.SetWarnings (True)


End Sub

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...dules/200603/1
 
Reply With Quote
 
 
 
 
tina
Guest
Posts: n/a
 
      31st Mar 2006
set the combo box's LimitToList property to No, and add the following code
to the combo box's AfterUpdate event, as

Private Sub Combo237_AfterUpdate()

If DCount("Prepayment", "tbl_GSPrepaypen", "Prepayment = '" _
& Me!Combo237 & "'") < 1 Then
If MsgBox("Add value to droplist?", _
vbYesNo + vbDefaultButton2) = vbYes Then
CurrentDb.Execute "INSERT INTO tbl_GSPrepaypen " _
& "( Prepayment ) SELECT '" & Me!Combo237 _
& "'", dbFailOnError
Me!Combo237.Requery
End If
End If

End Sub

hth


"The Joker via AccessMonster.com" <u17775@uwe> wrote in message
news:5e16c398da84e@uwe...
> Hello All,
> I am working on a pretty basic "add to combo box" function. What I am
> looking for is the user to have the option if they would like to add the

new
> information to the combo box. If they do it gets added (which works

fine),
> If they choose no I want them still to be able to submit the information

in
> the form but just not have it added to the combo box. How I currently

have
> it they have to add it or they can't use it, I get the "The text you

entered
> isn't in the list" error because I have set Limit to List "Yes".

Technically
> I don't want to limit to list. Any help will be greatly appreciated.

Thanks.
>
>
> Here is my code:
>
> Private Sub Combo237_NotInList(NewData As String, Response As Integer)
> ' this is the combo box for prepayment penaltys "add to combo" feature
>
> DoCmd.SetWarnings (False)
>
> Dim strSql As String
> If MsgBox(NewData & " is not in list, would you like to add it?", _
> vbYesNo + vbQuestion) = vbYes Then
> strSql = "insert into tbl_GSPrepaypen (Prepayment) values('" &

NewData &
> "')"
> CurrentDb.Execute strSql
> Response = acDataErrAdded
>
> End If
> DoCmd.SetWarnings (True)
>
>
> End Sub
>
> --
> Message posted via AccessMonster.com
> http://www.accessmonster.com/Uwe/For...dules/200603/1



 
Reply With Quote
 
=?Utf-8?B?S2xhdHV1?=
Guest
Posts: n/a
 
      31st Mar 2006
This site may help
http://www.pacificdb.com.au/MVP/Code/NIL.htm

"The Joker via AccessMonster.com" wrote:

> Hello All,
> I am working on a pretty basic "add to combo box" function. What I am
> looking for is the user to have the option if they would like to add the new
> information to the combo box. If they do it gets added (which works fine),
> If they choose no I want them still to be able to submit the information in
> the form but just not have it added to the combo box. How I currently have
> it they have to add it or they can't use it, I get the "The text you entered
> isn't in the list" error because I have set Limit to List "Yes". Technically
> I don't want to limit to list. Any help will be greatly appreciated. Thanks.
>
>
> Here is my code:
>
> Private Sub Combo237_NotInList(NewData As String, Response As Integer)
> ' this is the combo box for prepayment penaltys "add to combo" feature
>
> DoCmd.SetWarnings (False)
>
> Dim strSql As String
> If MsgBox(NewData & " is not in list, would you like to add it?", _
> vbYesNo + vbQuestion) = vbYes Then
> strSql = "insert into tbl_GSPrepaypen (Prepayment) values('" & NewData &
> "')"
> CurrentDb.Execute strSql
> Response = acDataErrAdded
>
> End If
> DoCmd.SetWarnings (True)
>
>
> End Sub
>
> --
> Message posted via AccessMonster.com
> http://www.accessmonster.com/Uwe/For...dules/200603/1
>

 
Reply With Quote
 
The Joker via AccessMonster.com
Guest
Posts: n/a
 
      31st Mar 2006
Thanks for your quick and educated responses. It works perfectly.

--
Message posted via http://www.accessmonster.com
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Access 2007 - Combo Boxes to break down list in othe combo box A_Barnes General Software 1 23rd Jul 2011 03:05 PM
combo box selection runs query to sum values in table not gettingparameter from combo box RCGUA Microsoft Access Form Coding 2 23rd Jul 2009 01:32 AM
Open form based on combo box value w/error message for blank combo box Ruth Microsoft Access 0 20th Apr 2007 11:00 PM
Two combo combo boxes on form to select specific report =?Utf-8?B?Q2h1Y2tX?= Microsoft Access Forms 1 12th Sep 2005 10:25 PM
"Combo Box - getting control combo box to stick in place in worksh =?Utf-8?B?YWpy?= Microsoft Excel Misc 0 15th Feb 2005 07:45 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:36 PM.