This may be an odd request....
I'm creating an Excel UserForm where the user can view, edit, and delete records they've entered.
The following code is for Deleting a selected record, and it IS WORKING. But it seems TOO SIMPLE and I want to be sure it's correct and not leaving any loose ends in the Database file that could cause corruption later on....
Code
Sub vCLdbDel()
Dim cnt As ADODB.Connection
Dim dbPath, dbName As String
Dim stSQLAs String
Dim stCon As String
Dim dbid As Long
Run "setvars"
'Get the dbID from the selected Item in the list
With vCL.CLdbList
dbid = .List(.ListIndex, 6)
End With
'Path & FileName to the Database File
dbPath = M.Range("G2").Value
dbName = M.Range("G3").Value
stCon = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & dbPath & dbName & ";"
'Initiate the ADODB-object.
Set cnt = New ADODB.Connection
'The SQL-statement to Delete the selected record.
stSQL = "DELETE FROM CallLog WHERE (CallLog.dbID = " & dbid & ")"
With cnt
'Open the connection
.Open stCon
.Execute (stSQL)
'Close the connections
.Close
End With
'Release objects from the memory.
Set cnt = Nothing
End Sub
Display More
Thanks in advance....