Page 1 of 2 12 LastLast
Results 1 to 15 of 20
  1. #1
    Join Date
    Jan 2004
    Location
    Baton Rouge, LA
    Posts
    26

    Unanswered: Using Multiselect Listbox to populate field

    Ok folks, I've asked this question before, but I think I've worded it incorrectly, because I just don't understand the answers that I got in return. Maybe this isn't possible, and I'm just spinning my wheels for not, but I think it can be done.

    I have a table that I use to keep track maintenance done on a signalized intersection. Some of the fields include simple things like the name of the intersection, the date and time it was visited, and who did the maintenance. Now I run into my problem.

    There are several groups of "problems" that they can check off on their sheet to show what is wrong with the signal. For instance, if they got there and found out that a red light and a green light were out, they would check those boxes for those two problem. What I'm trying to get at is that there can be multiple problems addressed at one time.

    I would like to build a listbox with a multiselect feature for this. Unfortunately, a basic listbox with multiselect will not save the data to the field. I will give an example below of one specific listbox i want to make.

    Listbox - "Display"
    Red, Yellow, Green, Right Arrow, Left Arrow, Straight Arrow, Walk, Don't Walk

    Now if a technician checks off "Green" and "Red" in the listbox, I want the field in the table that the listbox is bound to say "Green;Red" or something to that effect.

    I dont have ANY previous VB experience, else I would have coded this a long time ago. I also don't want to use check boxes for each individual item, else the table will be about 250 field heavy, most of which would be unused during a single record.

    Here's my SOS!!! If anyone has an idea, please let me know. I've looked back through the archives and have not found anything that pertains to this that understandable to me.

    Thanks so much!
    Beau B. "desigBEAU"

  2. #2
    Join Date
    Aug 2003
    Location
    Argentina
    Posts
    465
    You want make and string with the select item of the list box and then
    update a table field....???
    Saludos
    Norberto

  3. #3
    Join Date
    Jan 2004
    Location
    Baton Rouge, LA
    Posts
    26
    I want it so that if the items in the listbox "Red" and "Green" are selected out of the list of available items I mentioned before, then the field that the listbox is bound to will have "Red;Green" stored in it. Basically, whatever items that are selected, seperated by a semi-colon, or a comma, or a dash, something of that nature.

    So to answer your question, yes, I want to make a string out of whatever elements are selected and apply it to a table field. Preferably seperated by semicolons, etc.
    Last edited by desigBEAU; 01-28-04 at 18:36.
    Beau B. "desigBEAU"

  4. #4
    Join Date
    Aug 2003
    Location
    Argentina
    Posts
    465
    Originally posted by desigBEAU
    I want it so that if the items in the listbox "Red" and "Green" are selected out of the list of available items I mentioned before, then the field that the listbox is bound to will have "Red;Green" stored in it. Basically, whatever items that are selected, seperated by a semi-colon, or a comma, or a dash, something of that nature.

    So to answer your question, yes, I want to make a string out of whatever elements are selected and apply it to a table field. Preferably seperated by semicolons, etc.
    Is not easy......one question more
    How much you now abut VB?
    This answer is because i have some abut that but you must do the change for your especific problem....
    Saludos
    Norberto

  5. #5
    Join Date
    Jan 2004
    Location
    Baton Rouge, LA
    Posts
    26
    I dont know much about VB specifically, but I know enough about coding in general to know which things need to be changed in order to make it work. I know what the 'structure' of VB looks like.

    If you give me something that you know works and I can't make it work, then its a problem I'll have to deal with to figure it out. But as long as I know its supposed to work, I'll keep trying with it.

    Thanks!
    Beau B. "desigBEAU"

  6. #6
    Join Date
    Aug 2003
    Location
    Argentina
    Posts
    465
    Originally posted by desigBEAU
    I dont know much about VB specifically, but I know enough about coding in general to know which things need to be changed in order to make it work. I know what the 'structure' of VB looks like.

    If you give me something that you know works and I can't make it work, then its a problem I'll have to deal with to figure it out. But as long as I know its supposed to work, I'll keep trying with it.

    Thanks!
    Ok ...
    I prepare step by step what you must do.
    Give me a little of time
    Sorry for my english.
    Saludos
    Norberto

  7. #7
    Join Date
    Jan 2004
    Location
    Baton Rouge, LA
    Posts
    26
    Take your time... I've been working on this database for a month now, and this is the only stumbling block I've hit. As for the English, I have several student friends from Argentina, Honduras, and Guatemala. It's a barier that i don't mind crossing.
    Beau B. "desigBEAU"

  8. #8
    Join Date
    Aug 2003
    Location
    Argentina
    Posts
    465
    Originally posted by desigBEAU
    Take your time... I've been working on this database for a month now, and this is the only stumbling block I've hit. As for the English, I have several student friends from Argentina, Honduras, and Guatemala. It's a barier that i don't mind crossing.
    I hope this can help you.
    This is what you must do:
    1- Make a form.
    2- In this form make a Control List with Name:lisURLs
    RowSourceType: Table/Query
    RowSource:"YourQuery" ( This query must have only one column "Red, Blue,........")
    ColumnCount:1
    BoundColumn:1
    Enabled:Yes
    Locked:No
    MultiSelectimple
    3- Make a Command Botton with Name:cmdAdd
    Use the property On Click.
    In this property put this code:
    On Error GoTo Err_cmdAdd_Click
    Dim i As Integer
    Dim strIN As String
    Dim strWhere As String

    'create the IN string by looping thru the listbox
    For i = 0 To lisURLs.ListCount - 1
    If lisURLs.Selected(i) Then
    strIN = strIN & "'" & lisURLs.Column(0, i) & "',"
    End If
    Next i

    'create the strWhere string, stripping off the last comma of the strIN string
    strWhere = Left(strIN, Len(strIN) - 1)
    ' This field have the concatenate data for UPDATE the field on your table
    .........................
    .........................


    Exit_cmdAdd_Click:
    Exit Sub


    Err_cmdAdd_Click:

    MsgBox Err.Description
    Resume Exit_cmdAdd_Click

    Do that and tell me how work.......good luck (buena suerte).
    Saludos
    Norberto

  9. #9
    Join Date
    Jan 2004
    Location
    Baton Rouge, LA
    Posts
    26
    Originally posted by Norberto ' This field have the concatenate data for UPDATE the field on your table
    .........................
    .........................
    If the table is named tblLog and the field is named Direction, what UPDATE string would I use?
    Beau B. "desigBEAU"

  10. #10
    Join Date
    Aug 2003
    Location
    Argentina
    Posts
    465
    Originally posted by desigBEAU
    If the table is named tblLog and the field is named Direction, what UPDATE string would I use?
    With what criteria i found the record in the table for UPDATE i need one
    criteria....??????
    Saludos
    Norberto

  11. #11
    Join Date
    Jan 2004
    Location
    Baton Rouge, LA
    Posts
    26
    I guess I just dont understand. This isn't for a query. I'm not trying to "filter" records from a source. What is the use of the Update query? I was under the assumption that it was used to populate the field in the table. I'm gonna have to buy a VB book for access with my next pay check.
    Beau B. "desigBEAU"

  12. #12
    Join Date
    Aug 2003
    Location
    Argentina
    Posts
    465
    Originally posted by desigBEAU
    I guess I just dont understand. This isn't for a query. I'm not trying to "filter" records from a source. What is the use of the Update query? I was under the assumption that it was used to populate the field in the table. I'm gonna have to buy a VB book for access with my next pay check.
    See UPDATE in the help of Access
    UPDATE table
    SET newvalue
    WHERE criteria; <------- This i need

    Copyright (c) 1996 Microsoft Corporation
    Saludos
    Norberto

  13. #13
    Join Date
    Aug 2003
    Location
    Argentina
    Posts
    465
    The table have more than one records i need now which record i must update with the query. That is a criteria.
    Or your field is present in the form like a contrl box..?????
    You understand now.....
    Saludos
    Norberto

  14. #14
    Join Date
    Jan 2004
    Location
    Baton Rouge, LA
    Posts
    26
    Originally posted by Norberto
    The table have more than one records i need now which record i must update with the query. That is a criteria.
    Or your field is present in the form like a contrl box..?????
    You understand now.....
    The table will have a primary key named LogID. Does that help? I am thinking use the primary key as the criteria?

    Everytime I read a post, I think I know less and less about access! LOL.
    Beau B. "desigBEAU"

  15. #15
    Join Date
    Aug 2003
    Location
    Argentina
    Posts
    465
    Originally posted by desigBEAU
    The table will have a primary key named LogID. Does that help? I am thinking use the primary key as the criteria?

    Everytime I read a post, I think I know less and less about access! LOL.
    The question for a Millon....
    If a use the a primary key named LogID, i need now the name of the control in your form that have the LogID.
    Saludos
    Norberto

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •