May 15, 2008 at 3:15 am
Dear all Gurus / Masters
I do have another problem as follows
I am trying to loop in the record set of one table, my code is as follows
The following code is on a click event of a push button on a form
-- code starts here
Dim Conn As ADODB.Connection
Set Conn = New ADODB.Connection
Conn.Provider = "Microsoft.jet.OLEDB 4.0"
Conn.Open "C:\Study\STUDY_PAYROLL.mdb"
Dim MyTableRs As ADODB.Recordset
Set MyTableRs = ADODB.Recordset
MyTableRs.Open "COM_EMPMST", Conn, adOpenDynamic, adLockPessimistic
MyTableRs.MoveFirst
Do Until MyTableRs.EOF
mychk = DCount("[EMP_CODE]", [ATT_IMPMST], "[att_emp_code] = [EMP_CODE] and [att_date] = #02/05/2008#")
If mychk = 0 Then
MsgBox ("Employee Not Found in Attendance")
Else
MsgBox ("Employee found in attendance")
End If
Loop
MyTableRs.Close
Set MyTableRs.ActiveConnection = Nothing
Conn.Close
Set Conn = Nothing
-- code ends
Now, when I run this code I am getting error "Method or Data Member Not Found"
Please help me, I don't know why I am getting this error
b rgds
sunil joshi
May 15, 2008 at 6:02 am
You need to go find an MS Access forum for this type of question. This has nothing to do with SQL Server.
I think your DCount function is wrong.
I think it should be:
DCount("[EMP_CODE]", "[ATT_IMPMST]", "[att_emp_code] = [EMP_CODE] and [att_date] = #02/05/2008#")
You would also be better off using a "SELECT COUNT([EMP_CODE])" T-SQL statement. I think DCount creates a cursor and loops through it.
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply