I'm getting the following error:

You cannot add or change a record because a related record is required in table tblTerm.

I have a form with that is inserting records into the various tables and there's a one-to-many relationship between the tblterm and tblbilling tables and there is referential integrity turned on.  All the tables are inserting fine but the tblbilling table, which generates the error above.

Here is my insert code:

<CFQUERY NAME="InsertClient" DATASOURCE="esidb1">
INSERT INTO          tblMasterClients
                    (clientname, aliasname, infinity, svctype, acctstatus, siteid, authcode, pobox, poboxcombo,
                     did, secdid, faxdid, eighthundreddid, faxext, url, prepareddate, terminationreason, terminationdesc,
                     inactivedate, commencementanni, comments)

VALUES
                    ('#Form.clientname#',
                    '#Form.aliasname#',
                    '#Form.infinity#',
                    '#Form.svctype#',
                    '#Form.acctstatus#',
                    '#Form.siteid#',
                    '#Form.authcode#',
                    '#Form.pobox#',
                    '#Form.poboxcombo#',
                    '#Form.did#',
                    '#Form.secdid#',
                    '#Form.faxdid#',
                    '#Form.eighthundreddid#',
                    '#Form.faxext#',
                    '#Form.url#',
                    '#Form.prepareddate#',
                    '#Form.terminationreason#',
                    '#Form.terminationdesc#',
                    '#Form.inactivedate#',
                    '#Form.commencementanni#',
                    '#Form.comments#'
                    )
</CFQUERY>

<CFQUERY NAME="InsertClient" DATASOURCE="esidb1">
INSERT INTO          tbloccupants
                    (clientname, occname)

VALUES
                    ('#Form.clientname#',
                     '#Form.occname#'

                    )
</CFQUERY>

<CFQUERY NAME="InsertClient" DATASOURCE="esidb1">
INSERT INTO          tbllegaladdr
                    (legalname, legalcontact)

VALUES
                    ('#Form.clientname#',
                     '#Form.legalcontact#'

                    )
</CFQUERY>

<cfquery name="getreq" datasource="esidb1">
select [client name] as clientname

from tblbillingaddr

</cfquery>

<CFQUERY NAME="InsertClient" DATASOURCE="esidb1">
INSERT INTO           tblbillingaddr
               ([client name], billingcontact, billingemail)

VALUES
            ('#Form.clientname#',
             '#Form.billingcontact#',
             '#Form.billingemail#'
            )

</CFQUERY>

<CFQUERY NAME="InsertClient" DATASOURCE="esidb1">
INSERT INTO           tblterm
               (clientname, agrdate, agrstatus)

VALUES
            ('#Form.clientname#',
             '#Form.agrdate#',
             '#Form.agrstatus#'
            )

</CFQUERY>

<CFQUERY NAME="InsertClient" DATASOURCE="esidb1">
INSERT INTO           tblbillinglimits
               (clientname, conffreehrs, confrate)

VALUES
            ('#Form.clientname#',
             '#Form.conffreehrs#',
             '#Form.confrate#'
            )

</CFQUERY>

<CFQUERY NAME="InsertClient" DATASOURCE="esidb1">
INSERT INTO           tblbilling
               (lf, pcp)

VALUES
            ('#Form.lf#',
             '#Form.pcp#'
            )

</CFQUERY>

What's the magic required to insert the data into tblbilling?  Do I need to get the ID from tblterm and add where clause to the insert query?

Thanks!
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

Reply via email to