Thanks John, but I want to avoid using another table or a query if I can.
The listbox is on a form on its own which is loaded through code from another
form. According to the user's choices, many fields are combined into rows in
the list ready for pasting into a separate document. This text needs to be
in one control. (I originally used a text box, but the text soon got too big
for it.)
The text goes into the list box from string variables. I can't see how to
include quotemarks in a string. Can this be done? When I tried, it added
the variable name rather than the content.
The program stores questions, answers, subjects, etc for quizzes then pastes
chosen data into a separate document. Perhaps it would explain more if I
included some of the code:
Dim c As Control, fn As Boolean, inclSubj As Integer, s As String
Static qNum As Long
fn = IsLoaded("PasteToDocument")
If fn = False Then DoCmd.OpenForm "PasteToDocument"
If Forms!PasteToDocument!Text0.ListCount = 0 Then qNum = 1
inclSubj = MsgBox("Include the subjects?", vbYesNo, "Paste To Document")
For Each c In Forms!buildQuiz.Controls
If InStr(1, c.Name, "check", vbTextCompare) > 0 Then
If IsNumeric(Right$(c.Name, 1)) = True Then
If c.Value = -1 Then isChecked = 1
End If
End If
Next c
If isChecked = 0 Then
MsgBox "None of the check boxes are ticked"
Exit Sub
End If
If Check1.Value = -1 Then
s = CStr(qNum) & " "
If inclSubj = 6 Then
subject1.SetFocus
s = s & subject1.Text
Forms!PasteToDocument!Text0.AddItem s
question1.SetFocus
Forms!PasteToDocument!Text0.AddItem question1.Text
Else
question1.SetFocus
s = s & question1.Text
Forms!PasteToDocument!Text0.AddItem s
End If
answer1.SetFocus
Forms!PasteToDocument!Text0.AddItem answer1.Text
qNum = qNum + 1
End If
If Check2.Value = -1 Then
s = CStr(qNum) & " "
If inclSubj = 6 Then
subject2.SetFocus
s = s & subject2.Text
Forms!PasteToDocument!Text0.AddItem s
question2.SetFocus
Forms!PasteToDocument!Text0.AddItem question2.Text
Else
question2.SetFocus
s = s & question2.Text
Forms!PasteToDocument!Text0.AddItem s
End If
answer2.SetFocus
Forms!PasteToDocument!Text0.AddItem answer2.Text
qNum = qNum + 1
End If
If Check3.Value = -1 Then
etc...