اكثر الله خيرك
ها هو الكود
Private Sub LogIN_Click()
On Error Resume Next
MyUserName = Me.MyUser_Name
MyPassword = Me.MyPassword
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim qr As QueryDef
Dim sql As String
Set db = CurrentDb
sql = "select * from [users] where User_Name=[MyUserName] and User_Password=[MyPassword]"
Set qr = db.CreateQueryDef(vbNullString, sql)
With qr
.Parameters("MyUserName") = MyUserName
.Parameters("MyPassword") = MyPassword
.ReturnsRecords = True
Set rs = .OpenRecordset()
End With
If Not rs.EOF Then
conect = True
If rs.Fields("User_Active") = 0 Or DateFormat(rs.Fields("DateEnd")) < DateFormat(Now) Then
MsgBox "انتهى تنشيط هذا المستخدم", vbExclamation + vbOKOnly + vbMsgBoxRight, "تنبيه"
Else
MyUser_NO = rs.Fields("User_NO")
MyUserName = rs.Fields("User_Name")
DoCmd.Close acForm, "LogIn", acSaveYes
DoCmd.OpenForm "Form1"
End If
Else
conect = False
MsgBox "معلومات دخول غير صحيحة", vbCritical + vbOKOnly + vbMsgBoxRight, "تنبيه"
End If
End Sub
بارك الله فيك احترامى وتقديرى