Solved

ms access + remove values from combo box

Posted on 2011-02-15
11
353 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
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
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…

840 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