Access VBA: Put values of a multi-select list box into a Table -


I have a list box where I can select Monday-Friday. I can choose as many days as I want in the list box, if they want, then all I want to know is how to insert the list box in my table.

Here I have written code:

  Private subcommand 499_Click () set RstRecSet = nothing set db = CurrentDB slow dateDay string retard dateWeek string MsgBox form In (lstDateDay.Selected) "dateWeek = lstDateWeek.Value db.Execute" tblContacts (dateDay, dateWeek) in the value & quot; "('' And Detade and Android '', and 'DaveWeek End');" Db.Close end sub   

As you can see I'm trying different things. My problem list box is getting the price; It is showing in the form of tap, even if this data is selected.

I think what you think.

Edit: Salad

  set rs = db.OpenRecordset ("tblContacts") each itm lstDateWeek.ItemsSelected rs.AddNew Rs. for! DateWeek = lstDateWeek.ItemData (itm) Rs! DateDay = itm rs.Update Next RS Set up rs = None set db = nothing   

Date and date: You have columns in TLC contacts.

You used the selected collection from the items to get the index of items selected in the multi-selection list box And after that it has to be repeated and then the index will be used to reference the rows stored in the data collection. Just create a record set as part of this recurrence and add and update fields. There are different ways to handle this part, but I like it, shown below.

To use my sample, just create the TLTTist and the two column details (text) and the number of days as a number. Create a form and add a multi-select list box called dayoff wike. Fill it as a valilist with the days of the week and then add a button, which I keep on the store.

Try it by clicking on the code given below by clicking on the event

  Dim database database set the dirty rupee record set db = CurrentDb () set rs = db. OpenRecordset ("tblTest") in every itm DaysOfWeek.ItemsSelected rs.AddNew Rs! As for the details = DaysOfWeek.ItemData (itm) Rs! Private subcommand 19_Click () has dimmed:   

Set the Database Database Dims - Set records db = CurrentDb () Set to RS = db .OpenRecordset ("tblTest") for each in itm DaysOfWeek.ItemsSelected rs.AddNew bucks! Details = DaysOfWeek.ItemData (itm) Rs! Days = itm rs. Unrated rss. Set RSE = None Set DB = None End Sub

This can also be done with your AndS call which can be done by creating a selection string for your INSERT statement. But for me this is straightforward .. If you have any questions, then revisit me. If I can understand how to add my sample database.

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -