Hi, i am currently writing a code for a login screen. However I am getting a "run time error 424" object required. I have had very little experince using databases for programming. Any help on how to correct the issue would be greatly appreciated.

I am using visual basic 6 and MS access 2000


Login Form

Private Sub cmd_clear_Click()

txt_password.Text = ""      'Clear the password field
txt_userID.Text = ""      'Clear the username field

End Sub

Private Sub cmd_close_Click()

End     'close down the program

End Sub


Private Sub cmd_login_Click()

    rs.Open "Select * from user where ID='" & txt_userID.Text & "' and password='" & txt_password.Text & "'", cn, adOpenKeyset, adLockOptimistic
    If rs.RecordCount = 0 Then
        MsgBox "The user ID or Password is incorrect", vbCritical, "Failure"
    Else
       frm_main.Show
       Unload Me
    End If
    rs.Close

End Sub

Private Sub form_load()

txt_password.Text = ""      'Clear the password field
txt_userID.Text = ""      'Clear the username field

End Sub

module

Option Explicit

Public Function OpenDatabase(DatabasePath As String) As Boolean

Public cn As New ADODB.Connection
Public rc As New ADODB.Recordset
Public cnStr As String

Set cn = New ADODB.Connection

cnStr = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=D:\My Documents\School Work\Computing\Coursework\Database\CPT6 Database.mdb;" & DatabasePath

End Function

Thanks in advance

Reiko

reference missing maybe..

Ive fixed it, and now my login works 100% thanks for the help, however the referances were all in order. Thanks anyway.

well great...
happy coding friend :)

commented: thanks for direction +1

Hi, i am currently writing a code for a login screen. However I am getting a "run time error 424" object required. I have had very little experince using databases for programming. Any help on how to correct the issue would be greatly appreciated.

I am using visual basic 6 and MS access 2000


Login Form

Private Sub cmd_clear_Click()

txt_password.Text = ""      'Clear the password field
txt_userID.Text = ""      'Clear the username field

End Sub

Private Sub cmd_close_Click()

End     'close down the program

End Sub


Private Sub cmd_login_Click()

    rs.Open "Select * from user where ID='" & txt_userID.Text & "' and password='" & txt_password.Text & "'", cn, adOpenKeyset, adLockOptimistic
    If rs.RecordCount = 0 Then
        MsgBox "The user ID or Password is incorrect", vbCritical, "Failure"
    Else
       frm_main.Show
       Unload Me
    End If
    rs.Close

End Sub

Private Sub form_load()

txt_password.Text = ""      'Clear the password field
txt_userID.Text = ""      'Clear the username field

End Sub

module

Option Explicit

Public Function OpenDatabase(DatabasePath As String) As Boolean

Public cn As New ADODB.Connection
Public rc As New ADODB.Recordset
Public cnStr As String

Set cn = New ADODB.Connection

cnStr = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=D:\My Documents\School Work\Computing\Coursework\Database\CPT6 Database.mdb;" & DatabasePath

End Function

Thanks in advance

Reiko

hi Reiko...
i can see that u have used "rs" as ur record set instance in the form and "rc" as the record set in the module.Thats the cause for the 424 error.

hey Reiko...
grt to know u have fixed it...btw..wat was the issue?
references? the mismatch of recrd set names?
any other thing.?..i need help too on this..and am pretty new to VB...
can u help?
TIA

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.