Listbox to table help

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • troy_lee@comcast.net

    Listbox to table help

    I have a list box based on a query. I set the row source in vba with a
    dynamic string.

    I have a combo box at the top of the form that selects a unit number
    (formatted as text). This unit number is the PK for the main table.
    The listbox referenced above is used to create a rework report for the
    selected unit.

    What I need to do is grab the unit number from the combo box, (which
    we designate as [RMA #]- I know it's screwy and not right- not my
    fault) and each item in the list box and build an update query out of
    them for a table.

    The table has the unit number as the PK and is also the FK to the main
    table.

    So basically I need a string that looks like this and makes a unique
    record for each item in the list box:

    D0809100 (this is the unit number), Test Unit (one of the rows in the
    list box)
    D0809100, Shine Unit
    D0809100, Ship Unit
    etc., etc.

    Hopefully this is as clear as mud. Thanks in advance for the help.

    Troy
  • Salad

    #2
    Re: Listbox to table help

    troy_lee@comcas t.net wrote:
    I have a list box based on a query. I set the row source in vba with a
    dynamic string.
    >
    I have a combo box at the top of the form that selects a unit number
    (formatted as text). This unit number is the PK for the main table.
    The listbox referenced above is used to create a rework report for the
    selected unit.
    >
    What I need to do is grab the unit number from the combo box, (which
    we designate as [RMA #]- I know it's screwy and not right- not my
    fault) and each item in the list box and build an update query out of
    them for a table.
    >
    The table has the unit number as the PK and is also the FK to the main
    table.
    >
    So basically I need a string that looks like this and makes a unique
    record for each item in the list box:
    >
    D0809100 (this is the unit number), Test Unit (one of the rows in the
    list box)
    D0809100, Shine Unit
    D0809100, Ship Unit
    etc., etc.
    >
    Hopefully this is as clear as mud. Thanks in advance for the help.
    >
    Troy
    This might give you an idea on how to proceed. You can use Column() to
    determine which column of a listbox/combobox to use. The first element
    of a combo/listbox is 0. If you have ColumnHeadings set to True then
    start at element 1.

    Private Sub Command2_Click( )
    Dim intFor As Integer
    Dim strUnit As String
    strUnit = "D0809100"
    For intFor = 0 To Me.List0.ListCo unt - 1
    Debug.Print strUnit & ", " & Me.List0.Column (0, intFor)
    Next

    End Sub

    Comment

    Working...