Hey guys
I want to create a secure log in/ clock in / out form where different employees could log in and be automatically directed to there correct form. I have tried to create one but i keep getting "run time error 3011"

Dim WithEvents kell As Timer
Private Sub cmdin_Click()
'authenticate with a database
Me.Data1.RecordSource = "select *  FROM [EmployeeClock] WHERE [EmployeeID] = '" & Me.txtin & "'"
Me.Data1.Refresh

Select Case Data1.Recordset.RecordCount

Case Is < 1 'no record found
MsgBox "Not an Employee", vbCritical + vbOKOnly, "user error"
GoTo tidyform
Case Is > 1 'record found
If Data1.Recordset.Fields(1).Value = Me.txtpass.Text Then
Select Case Data1.Recordset.Fields(2).Value
Case "Mechanic"
Load frmmech
frmmech.Show
Case "Receptionist"
Load frmAdmin
frmAdmin.Show
Case "Driver"
Load frmmechanic
frmmechnic.Show
Case Else
MsgBox "Your Have Not Been Set A Role Please Contact Administrater"
End
End Select
Unload Me
Else
MsgBox "Tra", vbCritical + vbOKOnly, "bye!"
GoTo tidyform
End If

End Select
Exit Sub

tidyform:
              Me.txtin.Text = Empty
              Me.txtout.Text = Empty
              Me.txtin.SetFocus
           
                
End Sub
                 
Private Sub Form_Load()
strSQL = Me.Data1.DatabaseName = App.Path & "\EmployeeListlog.mdb"
End Sub

Private Sub Timer1_Timer()
lbltime.Caption = Format$(Time, "hh:mm:ss AM/PM")
    lbldate.Caption = Format$(Now, "dd, mm dd, yyyy")
End Sub

On which line? ... Run, hit debug, line should be highlighted. Also, include description of error as the error number 3011 is pretty much useless to people unless they know how to look up the error...

BTW: For those wanting to know how to look up an error, use the immediate window and type in err.raise 3011 and hit enter.

Good Luck

runtime error 3011 microsoft jet database engine cannot find object "select * FROM [EmployeeClock] WHERE [EmployeeID] = '" MAke sure the object exists and that you spell its name and pathname correctly

error line is me.data1.refresh

thanks

Which means your data control is not connected to the database. You must set its connect property and its databasename property before you set its recordsource property...

And not that I look over your code I see your problem... It is in your form load... remove the "strSQL = " and everything should be fine...

Good Luck

deleted it and set all properties ad still get the same error

thanks

So in form load you have...

Private Sub Form_Load()
Me.Data1.DatabaseName = App.Path & "\EmployeeListlog.mdb"
End Sub

and you are still having problems? What version of access?

Good Luck

put strsql.openrecordset in front of ("select.....

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.