0

I am using a pop up form with a combo box (cboPractices) that when a practice is selected in the combo box and double clicked, the value of the combo box is added to another form that is open (f_Requests) and creates a comma separated list in the txtPractices field. This does what I need it to do, but the problem I found is that sometimes when a value is double clicked, that value will replace the previous value in the master table...creating duplicate values. I only want the values selected to create a comma separated list in the txtPractices field, not replace the values in the master table. Can this be fixed?

The code I'm using is...

Private Sub cboPractices_DblClick(Cancel As Integer)

Dim txtP As String
txtP = Nz(Forms!f_Requests.txtPractices, "")

If Len(txtP) > 0 Then
    Forms!f_Requests.txtPractices = txtP & ", " & cboPractices
Else
    Forms!f_Requests.txtPractices = cboPractices
End If

End Sub
Erik A
  • 31,639
  • 12
  • 42
  • 67
Charlie
  • 25
  • 6
  • How many columns does `cboPractices` have? it might be worth referring to the precise column like `cboPractices.column(0)`. However, im not convinced that this is the cause of your error. – LiamH Nov 17 '15 at 14:28
  • It has 3 columns (practice, exempt and active). – Charlie Nov 17 '15 at 14:43
  • This sounds like your data is not normalized. Why create a comma separated list rather than separate entries in a table? – Fionnuala Nov 17 '15 at 16:26
  • I'm having users fill out a form and they can select several practices from a list of over 150 (the number of practices selected would vary for each record), then a report prints showing all the practices they selected. I tried the combo box where they can select multiple values with a checkbox, but that didn't seem to work with the database open by more than one user. I'm open to different ideas on how to make this work. – Charlie Nov 17 '15 at 16:42
  • I reckon you need a junction table: UserId, PracticeId this is more Normal https://en.wikipedia.org/wiki/Junction_table – Fionnuala Nov 17 '15 at 17:57
  • May also be of interest http://stackoverflow.com/questions/12131211/create-form-to-add-records-in-multiple-tables/12132196#12132196 – Fionnuala Nov 17 '15 at 18:01

0 Answers0