Ver Mensaje Individual
  #3 (permalink)  
Antiguo 05/01/2009, 03:45
Avatar de Taribo007
Taribo007
 
Fecha de Ingreso: agosto-2007
Mensajes: 1.338
Antigüedad: 16 años, 8 meses
Puntos: 18
Respuesta: Proteger diseño de consultas en Access.

Mediante el siguiente código se puede eliminar las entradas indeseadas con la tecla shift.

si no se entra con la clave indicada, se anula la entrada con la tecla shift, y entrando con la clave se activa para la próxima vez que se entre.

Private Sub Form_Open(Cancel As Integer)
Dim f As Date
Dim hoy As Date
Dim usr As String

usr = InputBox("Introduzca el nombre de usuario", "Usuario", "Pepito de los Palotes")

If usr <> "*** MI CLAVE SECRETA ***" Then
AlterarPropriedade "AllowBypassKey", dbBoolean, False
Else
AlterarPropriedade "AllowBypassKey", dbBoolean, True
End If
' Bomba de tiempo
' f = "1/1/2005"
' hoy = Date
'
' If hoy > f Then
' MsgBox "producto en fase demo"
' DoCmd.Quit
' Else
' DoCmd.Close acForm, "inicio"
' End If
DoCmd.Close acForm, "inicio"
End Sub

Public Function AlterarPropriedade(strPropName As String, varPropType As Variant, varPropValue As Variant) As Integer
Dim dbs As dao.Database, prp As dao.Property

Const conPropNotFoundError = 3270
Set dbs = CurrentDb
On Error GoTo Change_Err
dbs.Properties(strPropName) = varPropValue
AlterarPropriedade = True
Change_Bye:
Exit Function
Change_Err:
If Err = conPropNotFoundError Then ' Propiedad no ha sido localizada.
Set prp = dbs.CreateProperty(strPropName, varPropType, varPropValue)
dbs.Properties.Append prp
Resume Next
Else
' Error desconocido.
AlterarPropriedade = False
Resume Change_Bye
End If
End Function


Tienes que activar la libreria Microsoft DAO 3.6 object library
Un saludo