Hi.
I foresee a bright future for you in management.
I can envision many different ways to do that. Perhaps you've already set
this up? If not, the most common approach would probably be using a Word
template. (This would definitely _NOT_ be my choice, so if you pick it and
need help, please post a new question on how to do so.)
Create a text box on the form that is bound to that "field from one of the
tables." Here's some code that iterates through the list box, determines
which items are selected, compares the value with some "special" value and
concatenates it when the value matches, and then saves this value in a table.
Private Sub StoreLstBxSelBtn_Click()
On Error GoTo ErrHandler
Dim idx As Long
Dim sValue As String
For idx = 0 To (Me!lstList.ListCount - 1)
If (Me!lstList.Selected(idx)) Then
sValue = Me!lstList.ItemData(idx)
If (sValue = "special") Then
sValue = sValue & Me!txtSpecialValue.Value
End If
CurrentDb().Execute "INSERT INTO tblStuff (SomeValue) " & _
"VALUES ('" & sValue & "');", dbFailOnError
End If
Next idx
Exit Sub
ErrHandler:
MsgBox "Error in StoreLstBxSelBtn_Click( ) in" & vbCrLf & _
Me.Name & " form." & vbCrLf & vbCrLf & _
"Error #" & Err.Number & vbCrLf & Err.Description
Err.Clear
End Sub
. . . where lstList is the name of the list box, txtSpecialValue is the name
of the text box bound to the "field in one of the other tables," tblStuff is
the name of the table to store this temporary data, and SomeValue is the name
of the field to store the temporary data in.
If the code above doesn't shed some light, then please post your code and
we'll see whether we can help fix it.
If the listbox's row's Selected Property = TRUE, that means the row is
highlighted. FALSE means it's not highlighted. For example:
Me!lstList.Selected(4) = TRUE
This means that the 5th row displayed in the list box will be highlighted
when this code is executed. (Count in many collections starts at 0, not 1.)
HTH.
Gunny
See
http://www.QBuilt.com for all your database needs.
See
http://www.Access.QBuilt.com for Microsoft Access tips.
(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)
- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.