You are on page 1of 12

1

+, -. /0 12 34* " # $%& '( $ ) !


A @ ? 9 > 1;<= #50 -8 9: 70 ( 6* %5
J & G DH : I > E F 1 B. C+ %5 +, 1 & D?
A P 5 $QRD M N 1 +, 1 O A 3 8 L 8 GK
.$V 8 $ 8 TT . A S T 8 U #2 .4 T :T.

W
mahdiasihy@yahoo.com W

WI Q:
VB G N /0 @ ? 3 . R # Y< Z *X
\. ] / @ & ? /0 @ 2 ^_ % *[
VB
VB \. ] / Y 2 a% # b V8 *`
2

W $^ & Y2 & A_
Microsoft Access
$ % & '( ) (* " # ! ! " # !
userandpassword $ Table +, - . % & ' '! /01 2 3 Names
6 45!
3

77 :! UserName 77 - $ 8' 9 3" 4 " % & ' - ! 01 2 3


password 77! 3" 4 #! Input Mask ; ('! 77! 4 Password
- 4 <! = #! 4! 4 - > 3" 4 #! 01 !, ?! 23 ( ?!@ password
6 ! ! 45! 3" ! < A#% ! & %! &

! ! 1 VB677 C* # ! B. D& ' ! 9* B %


Visual J* F ' H # * I$ ! DAO EF G , #* , ), = % ),
< N ; #5 ! References -K2 9* BL M ), , ." 2 #* , B(4! Basic
F# ! ?$ ! # H P 2 3 Project F 9* , DAO & O *# ! 9* 94
0 (! /01 9* J. # ! , Q 0 #BRH B 8SM! ! References # 2
#2
4

$ F#! BH0 <! # ! P ? 3 %H 0 (! T S OK < 8S " 2 %

C* # % & '( ' (V >HUC* # ! B. % & '( )


! <! " # !
Command Buttons W Text Boxes W 9* ) 4 H B* O & '( ! 3
77! $ txtpassword 77 Text2 77! txtusername 77 Text1 7! $
*# ! B$ ! cmdcancel 77 Command2 77! cmdadd 77 Command1
6 ! ! -4
5

77! $ M , 1# S & ' Command Buttons 77! 95 - $(! *


6 ! ! -4 Cancel 77 Command2 77! Add 77 Command1

<' ! Text A0> & '( XF YO! 0 Text1 and Text2 77! $(! *
6 ! ! 45! !2

"B & %! PasswordChar 77! *K J txtpassword 77! $(! *


\\ [ Z *K J J $H +" 2 *K%! /01 O! 01 4H ! 4!
6 ! ! 45!
6

Add New User <! 95 &" L! # S & '( ) 95 &" L! I $ "0


6 ! ! 45!

6 ! ! 45! 1# 4H & %! &" L! # 4 ! "] %H

6 ! ! # 2 45! ) 4H 2 ^ (1 ) @ "0 B. ! 9* I B 9
_ I$4H '* N J H &" L! < Labels W E MH ) J $H 6 RNK*
_$ I$4 ! K 9 ` ! Password 77 :! UserName 7 - B $H
7

3 4! 4 & '( )
; #5 ! " ! _L Microsoft Access 77! E * J )`2 6 RNK*
: ! ! 3 4! ) 4 cmdadd 3 4! 4
Private Sub cmdadd_Click()
Dim dbs As DAO.Database
Dim rcd As DAO.Recordset
If Me.txtusername = "" Then
MsgBox "Enter Your Name Please", , "Your Name"
Me.txtusername.SetFocus
Exit Sub
ElseIf Me.txtpassword = "" Then
MsgBox "Your Password Please", , "Your Password"
Me.txtpassword.SetFocus
Exit Sub
Else
Set dbs = OpenDatabase(App.Path & “\Names.mdb”)
Set rcd = dbs.OpenRecordset(“userandpassword”)
With rcd
.AddNew
rcd!UserName = Me.txtusername
rcd!Password = Me.txtpassword
.Update
Me.txtusername.Text = ""
Me.txtpassword.Text = ""
End With
End If
End Sub
8

: ! ! 3 4! ) 4 cmdcancel 3 4! 01 4
Private sub cmdcancel_Click()
If msgbox(“Are You Sure?”,vbYesNo + vbQuestion,”Cancel”)=vbYes then
End
Else
Exit sub
End if
End sub
C* # ! 9* L $H ) ." - C* # ! 9* ( B

T #a 9 ! 9* 3" ! = "] ! & '($ :! C* # ! *


= ) @ K b :* c > &" L! & 'H 3 . * #$! 3 . *= ) 4 * ( +, VB
% c >! +, \ 041 :! &" L! d ! >! &" L! T e 3 . * #$! 3 . *
3 4! 01 3 4 & '( 01 (! :* \ #H I +0! c >! 4 & ' I ?
= ) ! " (! #H ) 3 . * #$! 3 . * +0! = ) @ ) 4
) - 'H ! " (! #H ) ) H3 . * # e #$! = ) @ ) H3 . * #$!
+ > C* # ! B. <$( ) ( \) H3 . * # e #$! =
6 3 /01 < B. !
Command Buttons W f Labels W -Text boxes W
7! txtpassword 7 Text2 7! txtusername 77 Text1 77! $ & '(
Label1and * cmdcancel 77 Command2 7! cmdok 7 Command1
4! 8' 1 (L , *# ! B. > ( B # S & ' K Label2
Max Button 77! % & ' USER NAME D &" L! $ B 9 (%!
77! *K J txtpassword 77! $(! * T $! g#5! 1# 4H & %! &" L !
+" 2 *K%! /01 O! 01 4H ! 4! " B & %! PasswordChar
\b ' BN# =H \\ [ Z *K J J $H
9 h# ^ (1 _ ! T $! i" ! 3 . * B d ! " j +, k "3 & 9!
6 ! ! F B(! 45! ) 4 +, T $! i" ! i" ! 01
9

6 ! ! & 4 cmdok 3 4! 3 4! k" 3 & '( )


Private Sub cmdok_Click()
Dim a As Boolean
Dim dbs As DAO.Database
Dim rcd As DAO.Recordset
If Me.txtusername = "" Or Me.txtPassword = "" Then
MsgBox "Please User Name and Password ", vbOKOnly + vbExclamation, "Incorrect"
Else
Set dbs = OpenDatabase(App.Path & “\Names.mdb”)
Set rcd = dbs.OpenRecordset("userandpassword")
With rcd
Do While Not .EOF
If rcd!UserName = Me.txtusername.Text And rcd!Password = Me.txtPassword.Text Then
a = True
Exit Do
Else
a = False
End If
.MoveNext
Loop
End With
If a = True Then
Msgbox”The Name is Available”,vbokonly,”Right”
Else
MsgBox "The Name is Unavailable", vbOKOnly + vbCritical, "Wrong"
Me.txtPassword.Text = ""
Me.txtPassword.SetFocus
End If
End If

End Sub
10

: ! ! 3 4! ) 4 cmdcancel 3 4! 01 4
Private sub cmdcancel_Click()
If msgbox(“Are You Sure?”,vbYesNo + vbQuestion,”Cancel”)=vbYes then
End
Else
Exit sub
End if
End sub
B(* 3 L ." l ) :! i" ! 9* ( B

VB T #a 9 " # ! & O $ ! = # SH m! :! C* # ! *
C* # ! B. 1 i" ! 01 g#5 & '( )
6 3 /01 < C* # ! n >
Command Buttons W f Labels o f n Text Boxes o
77 Text2 77! txtoldname 77 Text177! $ 3 ] "] $ & '( )
txtnewpassword 77 Text4 77! txtnewname 77 Text3 77! txtoldpassword
* cmdcancel 77 Command2 77! cmdchange 77 Command1 77!
*# ! =B. > ( =BF # S & ' K Label1,Label2,Label3,Label4
95 # SH <$( ) 8' 95 4! # SH +, =B 9 (%! 4! 8' =1 (L
Change User Name and 7 &" L! 01 I K: ? e" $N 01 &" L!
i "! &" L! # 4H & %! &" L ! Max Button 7! % & ' \Password
*K J txtnewpassword txtoldpassword 77! $(! * ' $!
/01 O! 01 4H ! 4! " B & %! B! % ! PasswordChar 77!
6 ! ! F B(! 45! ) 4 \\ [ Z *K J J $H +" 2 *K%!
11

6 ! ! ) 4 cmdchange 3 4! 4 & ' 3 % ! 3 4! " 3 . )


Private Sub cmdchange_Click()
Dim db As DAO.Database
Dim rcd As DAO.Recordset
Dim a As Boolean
If Me.txtoldname = "" And Me.txtnewname = "" And -
Me.txtoldpassword = "" And Me.txtnewpassword=”” Then
MsgBox "Fill all Data"
Me.txtoldname.SetFocus
Exit Sub
Else
Set db = OpenDatabase(App.Path & “\ Name.mdb”)
Set rcd = db.OpenRecordset("userandpassword")
With rcd
Do While Not .EOF
If rcd!UserName = Me.txtoldname And rcd! Password = -
Me.txtoldpassword Then
a = True
Exit Do
Else
a = False
End If
.MoveNext
Loop
End With
If a = True Then
rcd.Edit
rcd!UserName = ""
rcd! Password = ""
rcd!UserName = Me.txtnewname
rcd! Password = Me.txtnewpassword
Msgbox “ The Data have changed”
rcd.Update
Me.txtnewname.Text = ""
12

Me.txtoldname.Text = ""
Me.txtnewpassword.Text = ""
Me.txtoldpassword.Text = ""
Else
MsgBox "The Name You enterd Not Found"
Me.txtold.SetFocus
Exit Sub
End If

End If
End Sub
: ! ! 3 4! ) 4 cmdcancel 3 4! 01 4
Private sub cmdcancel_Click()
If msgbox(“Are You Sure?”,vbYesNo + vbQuestion,”Cancel”)=vbYes then
End
Else
Exit sub
End if
End sub
B(* 3 L ." cK:! i " ! 9* I B F`
=4F 3 X! 2 9* $(H

B p 9$N + B* 6 = 2
mahdiasihy@yahoo.com

You might also like