kinki_ngmy
06-26-02, 12:32
| in my form, there is a combobox(of product) and textbox(of price), once the combobox select a value, it will appear some value in textbox that related to the content of the same row. for example in table1 *record1: ID:3000 product:biscuit price:20 *record2: ID:3001 product: orange juice price:3 when the user select the product (biscuit) from combobox, automatically the textbox will apppear "20"(it work well), but now my problem is when i run this program(before adding new record), when press "next", the value of name will move next record by record. but let said i add record2 again. after saving, it will move to the first record. but the value of price is not 20, is 3,(the ID and product will move next or previous record by record, it work well)what's going on? i link the ID, product , price to ado_stock. so that it will save whatever value into table1. here are my code: _____________________________________________ Private Sub cbo_product_Click() Dim price As String price= "SELECT Price FROM table1 WHERE Product LIKE '" &cbo_product & "'" ado_price_sql.CommandType = adCmdText ado_price_sql.RecordSource = price Set txtPrice.DataSource = ado_price_sql ado_price_sql.Refresh End Sub __________________________________________ 'get the product from table_product Private Sub cbo_product_DropDown() cbo_product.Refresh cbo_product.Clear 'Clear the Combo box If ado_product.Recordset.RecordCount > 0 Then ado_product.Recordset.MoveFirst Do While Not ado_product.Recordset.EOF cbo_product.AddItem ado_product.Recordset.Fields("Product").Value ado_product.Recordset.MoveNext Loop End If cbo_product.Refresh End Sub ____________________________________________ Private Sub cmd_saveP_Click() ado_stock.Recordset.Fields("Product").Value=cbo_product.Text ado_stock.Recordset.Fields("Price").Value = txtPrice.Text ado_stock.Recordset.Save 'Save the record Call MsgBox("Your changes have been sucessfully made!", vbInformation, "Save") End Sub |