Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2003

    Unanswered: Insertion of new Records

    Hi there,
    I guess this is a newbie question, so here goes.

    I have two tables; Clients and Invoice
    I have one Form called; NewInvoice

    Clients DB:
    CustomerID (PK)

    Invoice DB:
    InvoiceID (PK)
    CustomerID (FK)

    Now, I want to create invoices for multiple clients at once.
    so in my NewInvoice form I have a Listbox which lists all the clients.
    I have enabled multiselect to SIMPLE.

    On my right side, I have a TextBox called 'InvoiceAmount' where I can type in an ammount. And then I have a button called 'AddNewInvoices'.

    How do I go about inserting new records into Invoice DB with the cliendIDs selected from the ListBox?

    When creating the listbokx (using a wizard) - I was asked if I wanted to remember selcted items for later use..... so I answered yes.

    Any help apprechiated!

  2. #2
    Join Date
    Oct 2003
    I would do a loop and insert for each selected item.

    set dbs=currentdb()
    for x = 0 to CustId.ListCount - 1
    set qdf=dbs.createquerydef("","Insert into Invoices ( Balance, CustomerId ) Select " & Balance & ", " & CustId.Selected(cnt) & ";")
    next x

Posting Permissions

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