Solved

ms access + remove values from combo box

Posted on 2011-02-15
11
354 Views
Last Modified: 2012-05-11
I have a form, and on the form there is a text box and a combo box, the text box is readonly, and the combo box is populated from a table.

The user selects a value from the combo box, and it adds what they selected to the value of the textbox.

is there a way to remove the value from the the combo box once selected, or a way to check the text in the textbox to see if the value was already added?  

The text box could have several words inside, each separated by a comma.
0
Comment
Question by:dkilby
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
11 Comments
 
LVL 75
ID: 34900503
What is the code you have for the combo box events now ?

mx
0
 

Author Comment

by:dkilby
ID: 34900530
i am using visual basic on the afterupdate event
0
 
LVL 75
ID: 34900538
Yes I know ... can you post that code ?

mx
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:dkilby
ID: 34900612
ah sorry - here is the code.

Private Sub cboKeywords_AfterUpdate()
    Dim str As String
   
    str = str & Me.cboKeywords
   
    Me.txtKeywords = Me.txtKeywords & str & ", "
End Sub
0
 
LVL 75
ID: 34900706
ok ...then to clear the combo:

Private Sub cboKeywords_AfterUpdate()
    Dim str As String
   
    str = str & Me.cboKeywords
   
    Me.txtKeywords = Me.txtKeywords & str & ", "

    Me.cboKeyWords= Null ' *********** add this

End Sub
0
 

Author Comment

by:dkilby
ID: 34900760
can i also check the value of txtKeywords to make sure the value of cboKeywords has not already been added?

0
 
LVL 75
ID: 34901957
sure ... stand by
0
 
LVL 75
ID: 34902012
Here you go.

mx
0
 

Author Comment

by:dkilby
ID: 34902050
i think the actual code is missing?
0
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 500 total points
ID: 34902061
ahh OOPS ! sorry

Private Sub cboKeywords_AfterUpdate()
    Dim str As String
   
    If InStr(1, Me.txtKeywords, Me.cboKeywords) > 0 Then
        MsgBox "Word already in string"
        Exit Sub
    End If
   
    str = str & Me.cboKeywords
   
    Me.txtKeywords = Me.txtKeywords & str & ", "

    Me.cboKeywords = Null ' *********** add this
End Sub
0
 

Author Closing Comment

by:dkilby
ID: 34902096
Perfect thanks for the help
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

697 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question