Adding text by using combo box.

  • Thread starter Thread starter JGrap
  • Start date Start date
J

JGrap

I would like to use items in a combobox to automatically fill in text
in another field. This would be used in the context of law citations,
for example:

Combobox items
(A)
(B)
(C)(1)

where (B) = "Negligence: description of law, etc."

Is it possible to continually select different "laws" from the
combobox and have the text box automatically fill with the full law
text? So basically I pick (B) in the combobox and it throws the text
into a separate text box, then I pick (A) and it puts that text in
below (B)in the same text box and so on.....Any help would be
appreciated. thanks in advance.
 
Just set the Click property to Event Procedure, then click the build button
to the right of the property to create a subroutine.
In the subroutine you append the selected item to the contents of the text
field, adding commas and separating spaces as desired.

Example:
Private Sub MyCombo_Click()
On Error GoTo Err_MyCombo_Click

If (IsNull(Me.MyList) Or (Me.MyList = "")) Then
Else
Me.MyTextBox = IIf(IsNull(Me.MyTextBox) _
Or (Me.MyTextBox = ""), _
Trim(Me.MyList), Me.MyTextBox & ", " _
& Trim(Me.MyList))
Me.MyList = ""
End If

Exit_MyCombo_Click:
Exit Sub

Err_MyCombo_Click:
MsgBox ("RUNTIME ERROR" & vbCrLf & "Source: " & Err.Source & vbCrLf _
& "Error # " & Err.Number & " | " & Err.Description)
Resume Exit_MyCombo_Click

End Sub

Where the name of the combo is MyCombo and the text box where you copy the
data to is MyText

Ragnar
 
Ragnar,
Sorry, my coding is mediocre at best. What does MyList refer to?
Would this work with a list box too? Thanks for your help!

-Josh
 
I got it to work, the only problem is it is limiting me to 256
characters. I have the field in the reference table set to memo and
it is showing the entire text for records over 256, but when I click
on the listbox (changed it from combo to list, and set it for
doubleclick event) it will only throw the first 256 characters out to
the text box. Any suggestions? Thanks!
 
Back
Top