Prikazi cijelu temu 22.10.2012 09:55
xl_kid Van mreze
Clan
Registrovan od:11.11.2008
Lokacija:-


Predmet:Ime i prezime logovanog usera
Poštovani,
imam problem sa logovanim korisnikom tj kako da dobijem ime i prezime iz tabele i upišem ga na unbound polju. Imam tabelu

tblUsers
KorisnikID int 4 0
KorisnickoIme nvarchar 50 1
Password nvarchar 50 1
Ime nvarchar 50 1
Prezime nvarchar 50 1
Pristup bit 1 1
Mesto nvarchar 25 1
Adresa nvarchar 30 1
Tel nvarchar 9 1
Mob nvarchar 10 1
Sifra nvarchar 25 1
PristupID int 4 1
DatumU datetime 8 1
VrstaPID int 4 1

Kako da iz ovog koda dobijem trenutno logovanog korisnika?

Public Sub Login()

On Error GoTo ErrorHandler:

If IsNull([txtUserName]) = True Then 'Check UserName
MsgBox "Korisnicko ime je obavezno"

ElseIf IsNull([txtPassword]) = True Then 'Check Password
MsgBox "Lozinka je obavezna"

Else

'Compare value of txtPassword with the saved Password in tblUser
If Me.txtPassword.Value = DLookup("Password", "tblUsers", "[KorisnickoIme]='" & Me.txtUserName.Value & "'") Then
strUser = Me.txtUserName.Value 'Set the value of strUser declared as Global Variable
strRole = DLookup("PristupID", "tblUsers", "[KorisnickoIme]='" & Me.txtUserName.Value & "'") 'set the value of strRole declared as Global Variable
'DoCmd.Close acForm, "frmLogOn", acSaveNo
MsgBox "Dobrodošli nazad, " & strUser, vbOKOnly, "Dobrodošli"
DoCmd.OpenForm "Form1", acNormal, "", "", , acNormal

Else
MsgBox "Pogrešna lozinka. Molim Vas pokušajte ponovo.", vbOKOnly, "Pogrešna lozinka"
intLogAttempt = intLogAttempt + 1
txtPassword.SetFocus

End If

End If

'Check if the user has 3 wrong log-in attempts and close the application
If intLogAttempt = 3 Then
MsgBox "Nemate pristup.Molim Vas kontaktirajte administratora." & vbCrLf & vbCrLf & _
"Aplikacija ce se ugasiti.", vbCritical, "Ogranicen Pristup!"
Application.Quit
End If

ErrorHandler:

End Sub

hvala