If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Delphi, C etc > textbox value cannot move to next

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-26-02, 11:32
kinki_ngmy kinki_ngmy is offline
Registered User
 
Join Date: Mar 2002
Location: malaysia
Posts: 9
textbox value cannot move to next

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_pr oduct.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
Reply With Quote
  #2 (permalink)  
Old 06-26-02, 14:03
rnealejr rnealejr is offline
Registered User
 
Join Date: Feb 2002
Posts: 2,232
When you save the record, you say it moves to the first record - what in your code is causing the recordset to move to the first record ? In this example, are there only the 2 records ? Are you using the ado data control ? Is the price of the 2nd record really in record 1 or are the fields just out of sync ?
Reply With Quote
  #3 (permalink)  
Old 06-26-02, 20:30
kinki_ngmy kinki_ngmy is offline
Registered User
 
Join Date: Mar 2002
Location: malaysia
Posts: 9
HELPPPPP!!!!!!!

yes, i 'm using ado control(.save).in my data base it is not only 2 record. under access, when u check back to the table which is table_stock, it is with different price, is not what that the price of the second record will replace the price of first record.but in form, when u run it before saving new record, "next" button u press, it works, the price will move to next record, but after u save it, u play "next", the price will be the same no matter which record u are state.
Reply With Quote
  #4 (permalink)  
Old 06-26-02, 20:39
kinki_ngmy kinki_ngmy is offline
Registered User
 
Join Date: Mar 2002
Location: malaysia
Posts: 9
HELP!!!!!!

yes, i ' m using ado (.save ) to save the record. check backto the database, the price is different, the second's record price will not replace the price of first record. but under visual basic, before save a new record contain a new price, pressing "next", it work well, it will move to the next record.but after saving a new record, press "next" button again, every record will state with the same price, but the value of combo box will move next, the problem is only the text box.
Reply With Quote
  #5 (permalink)  
Old 06-27-02, 09:01
rnealejr rnealejr is offline
Registered User
 
Join Date: Feb 2002
Posts: 2,232
Let me see if I understand the problem: You move next using the ado data control and everything is ok. But you click on your save button and the text box with a price stays the same for all records. But the database reflects the correct price, so basically you are losing the link between your text box and data control - the data in the database is not changing to this constant price that you see on your form. How are you creating a new record ? Could you post the mdb/vb project ?
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On