Im trying to delete records in a table. I've done it successfully but the datagrid does not refresh. what should i do? here's my code on cmdDelete:
Private Sub CmdDel_Click(Index As Integer)
'Declaring Variable to be used
Dim MyConn As ADODB.Connection
Dim mobjCmd As ADODB.Command
Dim mobjRst As ADODB.Recordset
'connecting to DB FB_CofF_Sync_test11_2000.mdb
Set MyConn = New ADODB.Connection
MyConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Chums\Documents\FB_DB\FB_CofF_Sync_test11_2000.mdb;Persist Security Info=False"
MyConn.Open
Set mobjCmd = New ADODB.Command
Set mobjCmd.ActiveConnection = MyConn
mobjCmd.CommandType = adCmdText
'check if you really want to delete this record
If MsgBox("Are you sure you want to delete all record?", vbYesNo + vbQuestion, "Delete?") = vbNo Then
Exit Sub
End If
'If DELETE YES = TRUE execute command
mobjCmd.CommandText = "DELETE * FROM f_7_fSpecies_new"
mobjCmd.Execute
DataGrid1.Refresh
Exit Sub
Private Sub CmdDel_Click(Index As Integer)
'Declaring Variable to be used
Dim MyConn As ADODB.Connection
Dim mobjCmd As ADODB.Command
Dim mobjRst As ADODB.Recordset
'connecting to DB FB_CofF_Sync_test11_2000.mdb
Set MyConn = New ADODB.Connection
MyConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Chums\Documents\FB_DB\FB_CofF_Sync_test11_2000.mdb;Persist Security Info=False"
MyConn.Open
Set mobjCmd = New ADODB.Command
Set mobjCmd.ActiveConnection = MyConn
mobjCmd.CommandType = adCmdText
'check if you really want to delete this record
If MsgBox("Are you sure you want to delete all record?", vbYesNo + vbQuestion, "Delete?") = vbNo Then
Exit Sub
End If
'If DELETE YES = TRUE execute command
mobjCmd.CommandText = "DELETE * FROM f_7_fSpecies_new"
mobjCmd.Execute
DataGrid1.Refresh
Exit Sub