
April 18th, 2004, 03:08 PM
|
 |
C A R D S
|
|
Join Date: Mar 2004
Location: The 'Ville
|
|
|
CFGRIDUPDATE error checking
I have a single page that, if CGI.REQUEST_METHOD IS "post" runs a CFGRIDUPDATE on a grid that is located in the same page. One of the columns in the page, PONumber, is a foreign key from another parent table.
I have to allow that column to be edited so that the other columns can be edited, but how can I check to see if the PONumber entered into this form for OrderItem acutally exists in MerchandiseOrder (I.E. - an order item cannont be entered with PONumber 1 if the MerchandiseOrder table does not have a record with PONumber 1).
Here's the code: http://cislab2.cbpa.louisville.edu/...7/orderItem.cfm
Code:
<CFIF CGI.REQUEST_METHOD IS "post">
<CFGRIDUPDATE datasource="#DataSource#" tablename="OrderItem" grid="orderItemGrid" keyonly="no">
</CFIF>
<CFQUERY datasource="#DataSource#" name="orderItemQuery">
SELECT PONumber, ItemID, Quantity, Cost
FROM OrderItem
ORDER BY PONumber
</CFQUERY>
<HTML>
<BODY>
<CFFORM action="orderItem.cfm">
<CFGRID name="orderItemGrid" query="orderItemQuery" insert="yes" delete="yes" griddataalign="left" gridlines="yes" rowheaders="no" colheaders="yes" colheaderalign="center" colheaderbold="yes" selectmode="edit" insertbutton="Insert Record" deletebutton="Delete Record" width="400"height="250">
<CFGRIDCOLUMN name="PONumber" header="P.O. Number">
<CFGRIDCOLUMN name="ItemID" header="Item I.D.">
<CFGRIDCOLUMN name="Quantity" header="Quantity Ordered">
<CFGRIDCOLUMN name="Cost" header="Purchase Cost" numberformat="$999.99">
</CFGRID>
<BR>
<INPUT type="submit" value="Save Changes">
</CFFORM>
</BODY>
</HTML>
ERD for the database is available here:
http://cislab1.cbpa.louisville.edu/...t5/petstore.jpg
I just need to print a message saying something like "PO Number does not exist" if that is true, or process the insert if the PO Number entered IS valid. Thanks in advance!
__________________
Reinventing the wheel again
|