Solved

ms access + remove values from combo box

Posted on 2011-02-15
11
350 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
  • 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
 

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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

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 - Access MVP) 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

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

744 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now