Adding a new order overwrite the last row in the table 
Author Message
 Adding a new order overwrite the last row in the table

I have a table of order detail data comprising of 1 P.key, 3 F.keys and 1
Qty field. Using a data environment to make the connection and recordsets
etc, I have got the new order part working but it overwrites the last row in
the table when it saves the first record of the new order. I have shown my
code below, I hope it isn't to tricky to understand. If someone wanted to
show me how to batch save so each order is only written to the table when it
is complete, whether 1 record or 10 records long - I would be appreciative.
Also, a question, please. Is it compulsory that I have to provide the
AutoNumber for the table when I add the record like I have?  I did it this
way because when I just wrote ...addnew I kept getting an error message
saying the aaction had been cancelled.
Thanks, here comes the code.
Chris
Private Sub cmdSaveItem_Click()
Dim autoVal, numVal, custVal, prodVal, qtyVal As Integer

    If txtProdCode.Text = "" Or txtQtyItem.Text = "" Then
    Exit Sub
    End If

autoVal = Val(Label6.Caption)
numVal = txtOrdNum.Text
custVal = txtCustItem.Text
prodVal = txtProdCode.Text
qtyVal = txtQtyItem.Text
DE1.rsrsOrderItem.AddNew
DE1.rsrsOrderItem!OrderDetailID = autoVal
DE1.rsrsOrderItem!OrderNo = numVal
DE1.rsrsOrderItem!ProductCode = prodVal
DE1.rsrsOrderItem!Qty = qtyVal
DE1.rsrsOrderItem!CustID = custVal
DE1.rsrsOrderItem.Update
DE1.rsrsOrderItem.Requery
Label6.Caption = (autoVal + 1)
Label6.Refresh
txtOrdNum.Text = frmCustomer.txtOrdNo8.Text
txtCustItem.Text = frmCustomer.txtCustID1.Text
End Sub



Fri, 10 Oct 2003 02:33:48 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Adding new rows to related tables on a dataset

2. Add new row to a table dynamically

3. trace new added rows of a table

4. adding a table row, without setting same defaults as previous row

5. row heights of table rows added by vba

6. DataGrid, don't want the last row (new record), how to remove

7. Format last row in table

8. Problem highlighting last row added with MSFlexGrid 6.0

9. Textbox/label which add a new line and remove the last line

10. need help please:joined tables,add new entries based on one table columns

11. need help please:joined tables,add new entries based on one table columns

12. How to add a new order?

 

 
Powered by phpBB® Forum Software