I have this simple coding for a login form in vb6 with connection to an Access database, but every time I compile this code, it shows an error:
Argument not optional
and highlights the Private Sub Loginbtn_Click()
and txtUsrName
.
Private Sub Command1_Click()
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=E:\Ash\New folder (2)\login form.mdb;" _
& "Persist Security Info=False"
conn.Open
Dim rs As New ADODB.Recordset
rs.Open "SELECT * FROM table1 WHERE username = '" & txtUsrName & "'", conn, adOpenStatic, adLockReadOnly
If rs.RecordCount <> 0 Then
If txtPwd = rs!Password Then
MsgBox "Username and Password Succesful!"
'Remove msgbox above then call a form to be load if login is succesful!
Call MDIForm1.Show
Else
MsgBox "Invalid Password, try again!", , "Login"
End If
Else
MsgBox "Invalid Login, try again!", , "Login"
End If
rs.Close
Set rs = Nothing
End Sub