heya
I have a subform with the products from my table. Next to each row there is a little button. Onclick that button the following code will be executed:
After clicking the button (and running code) the row is deleted but my form not directly refreshed/updated. There is somekind of weird delay in it....
Does anyone knows an answer.
I have a subform with the products from my table. Next to each row there is a little button. Onclick that button the following code will be executed:
Code:
Private Sub btnDelete_Click()
On Error GoTo Err_btnDelete_Click
'Dim some vars
Dim strSQL As String
Dim l_cmdTmp As New ADODB.Command
Dim l_rsTmp As ADODB.Recordset
l_sConnect = "PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=database.mdb;" & _
"User ID=admin;" & _
";Password="
'Set connection
Set m_cnConnection = New ADODB.Connection
With m_cnConnection
.ConnectionString = l_sConnect
.Open
.CursorLocation = adUseClient
End With
Set rs = New ADODB.Recordset
rs.ActiveConnection = CurrentProject.Connection
'Query
strSQL = "DELETE " & _
"FROM bestelproduct " & _
"WHERE ([Product_nr]= '" & Me.Product_nr.value & "' AND [Bestel_nr]= " & Me.Bestel_nr.value & " )"
'Run SQL
With l_cmdTmp
.ActiveConnection = m_cnConnection
.CommandText = strSQL
.CommandType = adCmdText
.CommandTimeout = 0
Set l_rsTmp = .Execute
End With
'Set recordset to modular variable
Set m_rsRecordset = l_rsTmp
'Refresh subform
Form_BestellingSubformulier.Requery
Form_BestellingSubformulier.Refresh
Exit_btnDelete_Click:
Exit Sub
Err_btnDelete_Click:
MsgBox Err.Description
Resume Exit_btnDelete_Click
End Sub
After clicking the button (and running code) the row is deleted but my form not directly refreshed/updated. There is somekind of weird delay in it....
Does anyone knows an answer.