i am getting a “method connetion of object_ current project failed” on the following line
rs.Open str_sel, CurrentProject.Connection, adOpenKeyset, adLockOptimistic when i want to logon to an Acces database. this is happening on some XP and Access 2003 and running on other machines. HAve installed Mdac2.8 but its not working.
Below is the code:Option Compare Database
Private Sub ACCEPT_Click()
Dim ls_username, ls_username_1, ls_password, ls_password_1 As String
Dim str_sel As String
Dim rs As Recordset
Dim rs_count As Integer
ls_username = Me.User_name.Value
ls_password = Me.password.Value
str_sel = “SELECT * FROM USERS WHERE [USERNAME] = ‘” & ls_username & “‘;”
If IsNull(ls_username) Then
MsgBox “Please enter username”, vbInformation, “Payroll Logon”
Else
Set rs = New ADODB.Recordset
rs.Open str_sel, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
rs_count = rs.RecordCount
If rs_count < 1 Then
MsgBox "Username Does not exist", vbCritical, "Payroll Logon"
Else
ls_password_1 = rs!password
If ls_password_1 <> ls_password Or IsNull(ls_password) Then
MsgBox “Please Enter Correct Password “, vbCritical, “Payroll Logon”
Else
gsusername = rs!Username
gsprofile = rs!Profile
gl_Full_name = rs!Full_name
DoCmd.Close
End If
End If
DoCmd.OpenForm “main”, acNormal
End if
End sub