Code Not Working

MARVELOUS MUGARI's Avatar, Join Date: Apr 2010
Newbie Member
can you pliz help me i have a code i want to use but i can't create a form from it


Code:
[ Dim r As New Recordset
Dim ct As Control
Dim cn As New Connection
Private Sub cmdexit_Click()
Unload Me
End Sub
Private Sub cmdstart_Click()
r.MoveFirst
Do While Not r.EOF
If UCase(Trim(TXTUN)) = UCase(Trim(r!Username)) And 
Trim(TXTPASS) = Trim(r!Password) Then
i = 1
frmMain.Show
frmlogin.Hide
Exit Do
End If
r.MoveNext
Loop
If i = 0 Then
MsgBox "Invalid user."
TXTUser = ""
TXTPASS = ""
End If
End Sub
Private Sub Form_Activate()
TXTUN.Text = ""
TXTPASS.Text = ""
End Sub
Private Sub Form_Load()
Dim i As Integer
With cn
.Provider = "Microsoft.Jet.OLEDB.4.0"
   .ConnectionString = "data source=" & App.Path & 
"\library.mdb"
    .Open
    End With
   r.Open "select * from login", cn, adOpenDynamic, 
adLockOptimistic
i = 0
End Sub]

Last edited by shabbir; 19Apr2010 at 09:11.. Reason: Code blocks
MARVELOUS MUGARI's Avatar, Join Date: Apr 2010
Newbie Member
I'm a beginner in programming can you pliz help me create a form from this login form code
looking fowad to a helpfull reply on malvy01@hotmail.com
Code:
 
[Dim r As New Recordset
Dim ct As Control
Dim cn As New Connection
Private Sub cmdexit_Click()
Unload Me
End Sub
Private Sub cmdstart_Click()
r.MoveFirst
Do While Not r.EOF
If UCase(Trim(TXTUN)) = UCase(Trim(r!Username)) And 
Trim(TXTPASS) = Trim(r!Password) Then
i = 1
frmMain.Show
frmlogin.Hide
Exit Do
End If
r.MoveNext
Loop
If i = 0 Then
MsgBox "Invalid user."
TXTUser = ""
TXTPASS = ""
End If
End Sub
Private Sub Form_Activate()
TXTUN.Text = ""
TXTPASS.Text = ""
End Sub
Private Sub Form_Load()
Dim i As Integer
With cn
.Provider = "Microsoft.Jet.OLEDB.4.0"
   .ConnectionString = "data source=" & App.Path & 
"\library.mdb"
    .Open
    End With
   r.Open "select * from login", cn, adOpenDynamic, 
adLockOptimistic
i = 0
End Sub]

Last edited by shabbir; 19Apr2010 at 09:11.. Reason: Code blocks
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
You have posted this under Introduction forum and I have moved it to VB forum
MARVELOUS MUGARI like this
virxen's Avatar, Join Date: Nov 2009
Pro contributor
here is your forms


change TXTUN --->TXTuser in your code
and put the code int the right place
Attached Files
File Type: rar g4.rar (1.4 KB, 8 views)
MARVELOUS MUGARI like this