Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / New Users / April 2005

Tip: Looking for answers? Try searching our database.

Adding Value to an existing Combo box

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Buz - 12 Apr 2005 17:46 GMT
Hi.
In table I created a combo box.
In the Form I would like the user to be able to choose from the drop down
menu the values already there but also to be able to add a new value as and
when but also to be able to have that value available with the existing
ones.
I know that when I type in a new value it only shows up on that record and
is not available again in a new record.
I saw in a sampe that you can set Access to pop up a message to the user to
dbl click the field, which then opens the table/form of which the combo box
belongs, so that they can enter the new value, close it and then choose it
from the refreshed combo box.
But I can't seem to get it right.
Please Help?
fredg - 12 Apr 2005 17:56 GMT
> Hi.
> In table I created a combo box.
[quoted text clipped - 10 lines]
> But I can't seem to get it right.
> Please Help?

Set the Combo Box LimitToList property to Yes.

Then code the Combo's NotInList event:

Private Sub ComboName_NotInList(NewData As String, Response As
Integer)

' Prompt user to verify they wish to add new value.
If MsgBox("Customer is not in the list. Add it?", vbOKCancel) = vbOK
Then
' Set Response argument to indicate that data is being added.
    Response = acDataErrAdded
    CurrentDb.Execute " INSERT INTO YourTableName(CustomerNameField)
SELECT '" & NewData & "';", dbFailOnError
Else
' If user chooses Cancel, suppress error message and undo changes.
    Response = acDataErrContinue
' Clear the name from the combo box.
    Me.ComboName = Null
End If

End Sub

Change YourTablename and CustomerNameField to whatever
the actual table and field names are.

Add your own error handling as needed.
Signature

Fred
Please only reply to this newsgroup.
I do not reply to personal email.

Buz - 12 Apr 2005 21:16 GMT
Thank you . Just the thing!

>> Hi.
>> In table I created a combo box.
[quoted text clipped - 43 lines]
>
> Add your own error handling as needed.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.