• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 359
  • Last Modified:

ms access + remove values from combo box

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
dkilby
Asked:
dkilby
  • 6
  • 5
1 Solution
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
What is the code you have for the combo box events now ?

mx
0
 
dkilbyAuthor Commented:
i am using visual basic on the afterupdate event
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
Yes I know ... can you post that code ?

mx
0
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 
dkilbyAuthor Commented:
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
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
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
 
dkilbyAuthor Commented:
can i also check the value of txtKeywords to make sure the value of cboKeywords has not already been added?

0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
sure ... stand by
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
Here you go.

mx
0
 
dkilbyAuthor Commented:
i think the actual code is missing?
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
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
 
dkilbyAuthor Commented:
Perfect thanks for the help
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now