0

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
C-Pound Guru
  • 15,967
  • 6
  • 46
  • 67

1 Answers1

0

I think you need just to change your MsgBox commands:

MsgBox "Invalid Password, try again!", , "Login"

to

MsgBox "Invalid Password, try again!", "Login"
shA.t
  • 16,580
  • 5
  • 54
  • 111