PDA

Click to See Complete Forum and Search --> : Help please....cannot delete


zach007
Jan 18th, 2006, 07:18 PM
Dear Experts,

Has anyone could help me please to fix this code...it always failed I tried many time?...This is a "Delete" button, when I press this button, it should be delete row/item on the database...but it always failed....here is the code:



Private Sub CommandButton3_Click()

Dim con As ADODB.Connection
Set con = New ADODB.Connection
con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\exercise.mdb"

Set rst = Execute_SQL_ReturnRecordSet("Select * from Item", False, "C:\exercise.mdb")

rst.MoveFirst
Do While rst.EOF = False
If UserForm1.txtqty.Text = rst.Fields("Item_Code").Value Then
Exit Do
End If
rst.MoveNext
Loop

TextBox3.Text = rst.Fields("Qty")

Application.ScreenRefresh
End Sub




When I select item no 1 (using a combo box), then when I press "Check Current Stock" it show its Qty which is "1"...BUT, when I select other item numbers, let say item code number 3 it still show the Qty for item number 1...???....

Please help with code corrections...

Thank you so much... :confused:

Jennifer

si_the_geek
Jan 18th, 2006, 08:30 PM
If you have any comments to help zach007, please post in the other copy of this thread here.

zach007, please do not post duplicate threads.