Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multi select list box

Status
Not open for further replies.

cristobalito

Technical User
Dec 20, 2001
12
GB
Hello dear people

When I use multi select on a list box, the selected items are not stored into the underlying table. In addition, when I move to the next record, the same values remain displayed on the list box.

I want to be able to store the chosen values with one record in the table, then as a new record is added the list box is empty again and the user can select the options in the list box that are relevant for the new record.

If I turn the multi select off, it is possible to store just one item from the list into the underlying table. I wish I knew how to do this with the multi select option? Can any one help out on this please?

Kindest Regards
CRISTOBALITO

 
Hey...

i'm in the process of building a form with a multi-select box... this is the code i'm using. i use a delete query to clear the table before starting... you may want to get rid of that.

let me know if you have any questions:

Private Sub subGetBooks()
Dim rstBooks As Recordset
Dim varBooks As Variant

DoCmd.SetWarnings False

Set dbs = DBEngine(0)(0)


DoCmd.OpenQuery ("qry_calcs_Clear tbl_Books")

Set rstBooks = dbs.OpenRecordset("tbl_Books", dbOpenTable)

For Each varBooks In [Forms]![frm_Main]![sfrm_Criteria]!lstBooks.ItemsSelected
rstBooks.AddNew
rstBooks!BookID = [Forms]![frm_Main]![sfrm_Criteria]!lstBooks.ItemData(varBooks)
rstBooks!searchID = varBooks
rstBooks.Update
Next
'[Forms]![frm_Main]![sfrm_Criteria]!lstBooks.Requery
rstBooks.Close
dbs.Close

End Sub
 
Hello EJC

thanks for your reply. I'm a bit new to VBA, can you tell me are your selected items stored within one field related to one record as this is what I'm trying to acheive? I think I some how need to seperate the selected list box items with a comma so that they can be stored into the respective field. Do you think this is possilble?

Kindest Regards
Cristobalito
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top