Thứ Ba

Tạo Form đăng nhập Trong access vba

Private Sub txtdn_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb()
Dim user, pass As String
user = Trim(txtuser.Value)
On Error Resume Next
pass = Trim(txtpass.Value)
Set rs = db.OpenRecordset("acount")
Dim tam As Integer
tam = 0
Do While rs.EOF = False
If rs!user = user And rs!pass = pass Then
    labela.Caption = "ban da dang nhap thanh cong"
    If MsgBox("Ok de vao thang chuong trinh", vbOKOnly + vbQuestion, "Thong bao!") = vbOK Then
    DoCmd.OpenForm "F_Khoi_Tao"
    DoCmd.Close acForm, "DANG_NHAP"
    End If
    tam = 1
    Exit Do
Else
    tam = 0

End If
    rs.MoveNext
Loop
If tam = 0 Then
    If dem <= 3 Then
        'MsgBox "Ban dang nhap sai Password hay Username", vbOKOnly + vbQuestion, "Thong bao!"
        labela.Caption = "Ban dang nhap sai Password hay Username"
        dem = dem + 1
        txtuser.Value = " "
        txtpass.Value = " "
        txtuser.SetFocus
    Else
        If MsgBox("Ban da dang nhap qua 3 lan", vbYesNo + vbQuestion, "Thong bao!") = vbOK Then
            DoCmd.Quit acQuitPrompt
        Else
        labela.Caption = "Ban da bi khoa chuong trinh"
        End If
        
    End If
End If
End Sub

1 nhận xét:

Unknown nói...

làm thế nào để lấy dữ liệu từ table rồi sử dụng trong code hả bạn?

Đăng nhận xét

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Blogger Templates