954,568 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Connection.Execute command to Delete Records from MS Access Database Table

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 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 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

SPereira
Newbie Poster
8 posts since Aug 2007
Reputation Points: 10
Solved Threads: 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 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 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

manoshailu
Junior Poster
105 posts since Jun 2007
Reputation Points: 34
Solved Threads: 10
 

try to use this

conn.begintrans
Conn.Execute "DELETE FROM <tablename> WHERE FIELD1 = '" & cmdField1.Text & "'"
conn.committrans
debasisdas
Posting Genius
6,872 posts since Feb 2007
Reputation Points: 666
Solved Threads: 434
 

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:)

SPereira
Newbie Poster
8 posts since Aug 2007
Reputation Points: 10
Solved Threads: 0
 

HI

Give the Follwing Cmds

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

vishvaabala
Newbie Poster
5 posts since Jul 2008
Reputation Points: 10
Solved Threads: 0
 

Hi

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

Thanks anyway.

SPereira
Newbie Poster
8 posts since Aug 2007
Reputation Points: 10
Solved Threads: 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!

Ariah
Newbie Poster
1 post since Feb 2011
Reputation Points: 10
Solved Threads: 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.

SPereira
Newbie Poster
8 posts since Aug 2007
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You