0

Hi Guys,

I have written a program in VB 6 wherein I want to delete a particular record from MS Access Database Table. I noticed that the record does not get deleted immediately. Only after I close the recordset it disappears. I have a Delete Command Button in a Form that deletes a particular record. After deletion, when I browse the records in the table I noticed that the record has not been deleted. It is only when I close the Form which closes the recordset to that table and when I reopen the recordset I notice that the record gets deleted then. My code is as follows.

Conn.Execute "DELETE FROM <tablename> WHERE FIELD1 = '" & cmdField1.Text & "'"

where Conn is set to a New Connection. So what I did was close the recordset and then reopen it again soon after the above command is executed as follows.

Rs.Close
Rs.Open "SELECT * FROM <tablename> ORDER BY FIELD1", Conn, , , cmdTable

Please let me know if I am doing this the right way or is there any other method of solving this issue? But I want to use the Connection.Execute command only.

Please help. Thanks.
SPereira

5
Contributors
7
Replies
14
Views
9 Years
Discussion Span
Last Post by SPereira
0

HI,

To Refresh the Recordset you can use the ReQuery which the query executes again to get the proper results.


Shailaja:)

Hi Guys,

I have written a program in VB 6 wherein I want to delete a particular record from MS Access Database Table. I noticed that the record does not get deleted immediately. Only after I close the recordset it disappears. I have a Delete Command Button in a Form that deletes a particular record. After deletion, when I browse the records in the table I noticed that the record has not been deleted. It is only when I close the Form which closes the recordset to that table and when I reopen the recordset I notice that the record gets deleted then. My code is as follows.

Conn.Execute "DELETE FROM <tablename> WHERE FIELD1 = '" & cmdField1.Text & "'"

where Conn is set to a New Connection. So what I did was close the recordset and then reopen it again soon after the above command is executed as follows.

Rs.Close
Rs.Open "SELECT * FROM <tablename> ORDER BY FIELD1", Conn, , , cmdTable

Please let me know if I am doing this the right way or is there any other method of solving this issue? But I want to use the Connection.Execute command only.

Please help. Thanks.
SPereira

0

try to use this

conn.begintrans
Conn.Execute "DELETE FROM <tablename> WHERE FIELD1 = '" & cmdField1.Text & "'"
conn.committrans
0

Hi Shailaja,

Thanks alot. The ReQuery option did the trick. Now I can move on with ease.

C Ya.

HI,

To Refresh the Recordset you can use the ReQuery which the query executes again to get the proper results.


Shailaja:)

0

HI

Give the Follwing Cmds

Con.Begintrans
Con.execute "Delete From Table Where Cond..."
Con.Commitrans

0

Hi

I did try the begintrans / committrans but it somehow didn't work out. But the Requery option did work.

Thanks anyway.

0

hi!:(
I'm Ariah,
I got problem with vb 6.0 codes to delete records from tables, w/c I used MS Access 2003 as my database. Can u please help me in coding? just give me a very simple code for this, without using any modules. . . ok? thanks a lot! hope u can help me too. . .
good day!

0

hi!:(
I'm Ariah,
I got problem with vb 6.0 codes to delete records from tables, w/c I used MS Access 2003 as my database. Can u please help me in coding? just give me a very simple code for this, without using any modules. . . ok? thanks a lot! hope u can help me too. . .
good day!

Refer to the previous posts. After using the Connection.Execute command refresh the Recordset using the ReQuery option.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.