Complex Insert

Results 1 to 4 of 4

Thread: Complex Insert

  1. #1
    Pat Williams Guest

    Default Complex Insert

    I have a large form that has to insert into multiple tables in an Access Database.<BR><BR>Part one inserts person details<BR>Part 2 consists of up to 40 check boxes.<BR><BR>Part two is the bit I have the problem with. How do I only do the insert for teh check boxes that have been selected?

  2. #2
    JFF Guest

    Default RE: Complex Insert

    do you mean this:<BR>&#039;you should have the same name for all checkboxes:<BR>chkBox=Request("box")&#039;values from checkboxes<BR>chkBox = split(chkBox,", ")<BR>...<BR>Insert table set colunm = &#039;"&chkBox(0)&"&#039;,colunm2= &#039;"&chkBox(1)&"&#039;,...<BR>

  3. #3
    xycodex Guest

    Default RE: Complex Insert

    if you can name the checkboxes yourself, then its easy.<BR>create another table with all the table names you need to insert to, then on the page proceeding the form, query the database for the tables, then cycle through the recordset and check the form collection for the checkbox, which should have the same name as the table and insert if the checkbox is "on"<BR>if you have to dynamically create the checkboxes, the same idea can be used: cycle through the &#039;tables&#039; table and plug in the checkbox code with the corresponding table name. :]

  4. #4
    Chaveiro Guest

    Default RE: Complex Insert

    A litle more information would help...<BR>this second table it&#039;s a table with 40 fields type true/false ?<BR>If so, then the alternative gave by the JFF won&#039;t work... i would make just a little change... every checkbox has the same name, but the value it&#039;s the name of the field... then the Insert:<BR>SQL = "INSERT table SET "<BR>For i = LBound(chkBox) To UBound(chkBox)<BR> SQL = SQL & chkBox(0) & " = 1, "<BR>NEXT<BR>&#039;this will create a last ,<BR>SQL = Left(SQL,Len(SQL)-1)<BR>SQL = SQL & " WHERE bla bla "<BR><BR>if not the case... than send another post...<BR>see ya...

Posting Permissions

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