Kod:
Public Function ValidatePW(Password As String, Username As String, DomainName As String) As Boolean
' Start by retrieving the user's name
Dim lpBuffer As String, nSize As Long
Dim rv As Long, usrName As String
Dim hToken As Long
' Initialise an empty buffer, 10 characters long (long enough for most user names)
lpBuffer = String(10, Chr(0))
Do
nSize = Len(lpBuffer)
rv = GetUserName(lpBuffer, nSize)
If rv = 0 Then
' The function probably failed due to the buffer being too small
' nSize holds the required size
lpBuffer = String(nSize, Chr(0)) ' Resize buffer to accomodate big name
End If
Loop Until rv <> 0
' Extract user name from buffer
usrName = Left(lpBuffer, nSize - 1)
If usrName <> Username Then
MsgBox "Kullanıcı adınız yanlış"
Exit Function
End If
If Domain() <> DomainName Then
MsgBox "Kullanıcı Alan adı yanlış"
Exit Function
End If
' Now validate the password
rv = LogonUser(usrName, vbNullString, Password, LOGON32_LOGON_NETWORK, LOGON32_PROVIDER_DEFAULT, hToken)
If rv <> 0 Then
' Password validated successfully
MsgBox "Şifre Doğrulandı."
Else
' Username and password failed validation
MsgBox "Kullanıcı adı ve şifre doğrulaması başarısız oldu."
End If
End Function
Kod:
MsgBox "Şifre Doğrulandı."
Kod:
docmd.quit
DoCmd.OpenForm "form1"
Böylece Form1 adındaki form açılacaktır.
Formun görünüm modu için kodların sonuna
,acNormal
Parametresi eklenebilir . Son komutla formu tasarım modunda açar. Bu görünüm modları şöyle:
acDesign : Tasarım görünümlü form
acFormDS : Veri sayfası görünümlü form
acFormPivotChart: Pivot chart görünümlü form
acFormPivotTable: Pivot tablo görünümlü form
acNormal: Normal görünüm
acPreview: Formu Baskı önizleme görünümü
Kolay gelsin...