Hi guys. I just wanted to ask you help in this tricky little thingy. I'm trying to create a log in action which takes the username and password from an access .mdb file and verifies it with the ones entered in a text box. but somehow I seem to be getting a Run - time error 91 (Object variable or With block variable not set)
The code is as below and the problematic line of coding has been highlighted.
I have added a reference to the ADO and also created a module which goes like thisCode:Private Sub login_btn_Click() Set rs = db.OpenRecordset("Select emp_username from employee where emp_username = '" & username_txt.Text & "'") If Not rs.RecordCount = 0 Then Set rs = db.OpenRecordset("Select emp_pass from employee where emp_pass = '" & password_txt.Text & "'") If Not rs.RecordCount = 0 Then login_frame.Visible = False 'hide login frame welcome_frame.Visible = True 'unhide welcome frame btn_home.Visible = False 'unhide buttons btn_rent_car.Visible = False btn_customer.Visible = False btn_car.Visible = False btn_account.Visible = False btn_employee.Visible = False Else MsgBox "Password incorrect" password_txt.SetFocus End If Else MsgBox "Username incorrect" username_txt.SetFocus End If End Sub
I'm still doing my diploma so any help at all would be greatly appreciated. Thanking you guys i advance.Code:Public rs As DAO.Recordset Public db As DAO.Database Public Sub Main() Set db = OpenDatabase(App.Path + "/EasyRent.mdb") main_form.Show End Sub




Reply With Quote