Function BorrarObjeto(nombreBD As String, nombreObjeto As String, tipoObjeto As Integer) Dim dbs As DAO.Database Dim prp As DAO.Property Dim AntiguoFormInicio As String Dim app As Object 'aquí nos cepillamos el formulario de inicio 'si existe On Error Resume Next Set dbs = OpenDatabase(nombreBD) AntiguoFormInicio = dbs.Properties("StartUpForm").Value dbs.Properties.Delete "StartUpForm" dbs.Properties.Refresh 'ahora abrimos la bd para borrar y todo eso Set app = CreateObject("Access.Application") app.OpenCurrentDatabase nombreBD 'la variable tipoObjeto será una constante del tipo 'acTable,acQuery,acForm,acReport, etc app.DoCmd.DeleteObject tipoObjeto, nombreObjeto app.CloseCurrentDatabase Set app = Nothing 'si había formulario de inicio y nos lo habíamos cargado 'lo volvemos a crear y lo dejamos como estaba If AntiguoFormInicio <> "" Then Set prp = dbs.CreateProperty("StartUpForm", dbText, AntiguoFormInicio) dbs.Properties.Append prp End If Set dbs = Nothing End Function