heya
I have a subform with the products from my table. Next to each row there is a little button. Onclick that button results that the following code will be executed:
After clicking the button (and running code) the row is deleted. The weird thing is that my form is not updated directly. First I see #deleted# at the unique column and when I focus on another field the row is going to be deleted....
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 results that the following code will be executed:
Code:
Private Sub Knop14_Click()
On Error GoTo Err_Knop14_Click
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=C:\Documents and Settings\gebruiker\Desktop\Bier_final_2.3.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
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
Form_BestellingSubformulier.Requery
Form_BestellingSubformulier.Refresh
Exit_Knop14_Click:
Exit Sub
Err_Knop14_Click:
MsgBox Err.Description
Resume Exit_Knop14_Click
End Sub
After clicking the button (and running code) the row is deleted. The weird thing is that my form is not updated directly. First I see #deleted# at the unique column and when I focus on another field the row is going to be deleted....
Does anyone knows an answer.