How to utilize a multiselect ListBox to add data to a table Unicorn Meta Zoo #1: Why another...

Why I cannot instantiate a class whose constructor is private in a friend class?

"Working on a knee"

Retract an already submitted Recommendation Letter (written for an undergrad student)

Protagonist's race is hidden - should I reveal it?

Writing a T-SQL stored procedure to receive 4 numbers and insert them into a table

What to do with someone that cheated their way though university and a PhD program?

false 'Security alert' from Google - every login generates mails from 'no-reply@accounts.google.com'

How would it unbalance gameplay to rule that Weapon Master allows for picking a fighting style?

Coin Game with infinite paradox

What is the evidence that custom checks in Northern Ireland are going to result in violence?

Suing a Police Officer Instead of the Police Department

My admission is revoked after accepting the admission offer

Mechanism of the formation of peracetic acid

Is it appropriate to mention a relatable company blog post when you're asked about the company?

What is the ongoing value of the Kanban board to the developers as opposed to management

Is it OK if I do not take the receipt in Germany?

What helicopter has the most rotor blades?

Why did Europeans not widely domesticate foxes?

A journey... into the MIND

Is Bran literally the world's memory?

Does a Draconic Bloodline sorcerer's doubled proficiency bonus for Charisma checks against dragons apply to all dragon types or only the chosen one?

Determinant of a matrix with 2 equal rows

Where/What are Arya's scars from?

Is a self contained air-bullet cartridge feasible?



How to utilize a multiselect ListBox to add data to a table



Unicorn Meta Zoo #1: Why another podcast?
Announcing the arrival of Valued Associate #679: Cesar ManaraHow can I add a field to a MS Access 2002 form which relates to another table?MS Access 2010 Expression error when using Column filter - “The expression ”|“ you entered is invalid.”Inserting Autotext (or Quickpart) into Word (2013) on the basis of a Boolean value from Access (2013)Miscrosoft Access - Multi-Table Data EntryAccess - Link two records in same table / calculation of field from the recordsMS Access database with large amounts of text crashes often and loses dataHow to exclude pieces of a record in query countHow do you add a calculated column in an Access 2010 pivot tableAdd new linked table to SQLServer-Access databaseJoin Query on a “blank” Table - Need it to add when updating





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







1















I have a form above. the short of my question is: I want to select a project # from dropdown, then select multiple companies from ListBox. And have them added to the table, i.e. project#, company#. I have one table for projects and another for companies. I have set up a table for linked projects/companies to keep the records in. You can have multiple companies involved in 1 project.



Could someone please help with this?



My code is:



Private Sub UpdateSelected()
Dim xPR As String 'variable for project id to use same # for each data row insert
Dim xCR As String 'variable for company id to use selected # for each data row insert
Dim xselected As Boolean

xPR = PtblProjectIDComboBox.SelectedValue
xPR = Convert.ToInt32(xPR)

For i = 0 To ListBox1.Items.Count - 1 'count to stroll thru company db and check if selected
If ListBox1.GetSelected(i) = True Then 'if selected then add record project # and selected company#
xCR = Convert.ToInt32(ListBox1.ValueMember)
xselected = True
TableGroupProjectTableAdapter.Insert(xPR, xCR, xselected) 'add the record if it is valid

'update db
Validate()
TableAdapterManager.UpdateAll(CMDB1copy2DataSet)
End If
Next i
End Sub


Screenshot of the input form:



screenshot of input form










share|improve this question









New contributor




James W. Brumbaugh Sr. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



























    1















    I have a form above. the short of my question is: I want to select a project # from dropdown, then select multiple companies from ListBox. And have them added to the table, i.e. project#, company#. I have one table for projects and another for companies. I have set up a table for linked projects/companies to keep the records in. You can have multiple companies involved in 1 project.



    Could someone please help with this?



    My code is:



    Private Sub UpdateSelected()
    Dim xPR As String 'variable for project id to use same # for each data row insert
    Dim xCR As String 'variable for company id to use selected # for each data row insert
    Dim xselected As Boolean

    xPR = PtblProjectIDComboBox.SelectedValue
    xPR = Convert.ToInt32(xPR)

    For i = 0 To ListBox1.Items.Count - 1 'count to stroll thru company db and check if selected
    If ListBox1.GetSelected(i) = True Then 'if selected then add record project # and selected company#
    xCR = Convert.ToInt32(ListBox1.ValueMember)
    xselected = True
    TableGroupProjectTableAdapter.Insert(xPR, xCR, xselected) 'add the record if it is valid

    'update db
    Validate()
    TableAdapterManager.UpdateAll(CMDB1copy2DataSet)
    End If
    Next i
    End Sub


    Screenshot of the input form:



    screenshot of input form










    share|improve this question









    New contributor




    James W. Brumbaugh Sr. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.























      1












      1








      1








      I have a form above. the short of my question is: I want to select a project # from dropdown, then select multiple companies from ListBox. And have them added to the table, i.e. project#, company#. I have one table for projects and another for companies. I have set up a table for linked projects/companies to keep the records in. You can have multiple companies involved in 1 project.



      Could someone please help with this?



      My code is:



      Private Sub UpdateSelected()
      Dim xPR As String 'variable for project id to use same # for each data row insert
      Dim xCR As String 'variable for company id to use selected # for each data row insert
      Dim xselected As Boolean

      xPR = PtblProjectIDComboBox.SelectedValue
      xPR = Convert.ToInt32(xPR)

      For i = 0 To ListBox1.Items.Count - 1 'count to stroll thru company db and check if selected
      If ListBox1.GetSelected(i) = True Then 'if selected then add record project # and selected company#
      xCR = Convert.ToInt32(ListBox1.ValueMember)
      xselected = True
      TableGroupProjectTableAdapter.Insert(xPR, xCR, xselected) 'add the record if it is valid

      'update db
      Validate()
      TableAdapterManager.UpdateAll(CMDB1copy2DataSet)
      End If
      Next i
      End Sub


      Screenshot of the input form:



      screenshot of input form










      share|improve this question









      New contributor




      James W. Brumbaugh Sr. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.












      I have a form above. the short of my question is: I want to select a project # from dropdown, then select multiple companies from ListBox. And have them added to the table, i.e. project#, company#. I have one table for projects and another for companies. I have set up a table for linked projects/companies to keep the records in. You can have multiple companies involved in 1 project.



      Could someone please help with this?



      My code is:



      Private Sub UpdateSelected()
      Dim xPR As String 'variable for project id to use same # for each data row insert
      Dim xCR As String 'variable for company id to use selected # for each data row insert
      Dim xselected As Boolean

      xPR = PtblProjectIDComboBox.SelectedValue
      xPR = Convert.ToInt32(xPR)

      For i = 0 To ListBox1.Items.Count - 1 'count to stroll thru company db and check if selected
      If ListBox1.GetSelected(i) = True Then 'if selected then add record project # and selected company#
      xCR = Convert.ToInt32(ListBox1.ValueMember)
      xselected = True
      TableGroupProjectTableAdapter.Insert(xPR, xCR, xselected) 'add the record if it is valid

      'update db
      Validate()
      TableAdapterManager.UpdateAll(CMDB1copy2DataSet)
      End If
      Next i
      End Sub


      Screenshot of the input form:



      screenshot of input form







      microsoft-access visual-studio-2017






      share|improve this question









      New contributor




      James W. Brumbaugh Sr. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question









      New contributor




      James W. Brumbaugh Sr. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question








      edited 10 hours ago









      zx485

      1,4672914




      1,4672914






      New contributor




      James W. Brumbaugh Sr. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 11 hours ago









      James W. Brumbaugh Sr.James W. Brumbaugh Sr.

      61




      61




      New contributor




      James W. Brumbaugh Sr. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      James W. Brumbaugh Sr. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      James W. Brumbaugh Sr. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          0






          active

          oldest

          votes












          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "3"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });






          James W. Brumbaugh Sr. is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1428745%2fhow-to-utilize-a-multiselect-listbox-to-add-data-to-a-table%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          James W. Brumbaugh Sr. is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          James W. Brumbaugh Sr. is a new contributor. Be nice, and check out our Code of Conduct.













          James W. Brumbaugh Sr. is a new contributor. Be nice, and check out our Code of Conduct.












          James W. Brumbaugh Sr. is a new contributor. Be nice, and check out our Code of Conduct.
















          Thanks for contributing an answer to Super User!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1428745%2fhow-to-utilize-a-multiselect-listbox-to-add-data-to-a-table%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Couldn't open a raw socket. Error: Permission denied (13) (nmap)Is it possible to run networking commands...

          VNC viewer RFB protocol error: bad desktop size 0x0I Cannot Type the Key 'd' (lowercase) in VNC Viewer...

          Why not use the yoke to control yaw, as well as pitch and roll? Announcing the arrival of...