Quote:
Originally Posted by hstiwari
I am trying to run the following code :-----
Public Function Fill() As Variant
Dim reccheck As ADODB.Recordset
Dim fldcheck As ADODB.Field
Set reccheck = New ADODB.Recordset
Set reccheck.ActiveConnection = CurrentProject.Connection
Dim str As String
str = Format(curdate.Value, "dd/mmm/yy")
reccheck.Source = "work_details"
reccheck.Open "select tslot2 from work_details where emp_id=" & Text13.Value & " and current_date = " & str & "; "
reccheck.MoveFirst
I am getting the following erroe:----run time error -2147467259(80004005)-Method 'Open' of object _recordset failed
Can any body help me????
See if this syntax works. This syntax is based on the ADO example at this link:
http://allenbrowne.com/func-ADO.html -
Public Function Fill() As Variant
-
-
'Declarations
-
Dim reccheck As ADODB.Recordset
-
Dim fldcheck As ADODB.Field
-
-
'Obtain a criterion for WHERE clause, and
-
'construct Select statement
-
-
Dim str As String
-
str = Format(curdate.Value, "dd/mmm/yy")
-
str = "select tslot2 from work_details where emp_id=" & Text13.Value & " and current_date = " & str & "; "
-
-
'open the recordset
-
Set reccheck = New ADODB.Recordset
-
reccheck.Open str, CurrentProject.Connection
-
-
'Loop through recordset until EOF
-
Do While Not reccheck.EOF
-
Debug.Print reccheck!tslot2 & ";" & reccheck!emp_id & ";" & reccheck(str)
-
reccheck.MoveNext
-
Loop
-
-
'Clean up objects and links
-
reccheck.Close
-
Set reccheck = Nothing