Connecting Tech Pros Worldwide Forums | Help | Site Map

run time error -2147467259(80004005)-

Newbie
 
Join Date: Jan 2008
Posts: 1
#1: Jan 1 '08
I am trying to run the following code :-----
Expand|Select|Wrap|Line Numbers
  1. Public Function Fill() As Variant
  2. Dim reccheck As ADODB.Recordset
  3. Dim fldcheck As ADODB.Field
  4. Set reccheck = New ADODB.Recordset
  5. Set reccheck.ActiveConnection = CurrentProject.Connection
  6. Dim str As String
  7. str = Format(curdate.Value, "dd/mmm/yy")
  8. reccheck.Source = "work_details"
  9. reccheck.Open "select tslot2 from work_details where emp_id=" & Text13.Value & " and current_date = " & str & "; "
  10. reccheck.MoveFirst
I am getting the following erroe:----run time error -2147467259(80004005)-Method 'Open' of object _recordset failed

Can any body help me????

puppydogbuddy's Avatar
Expert
 
Join Date: May 2007
Location: Florida
Posts: 1,915
#2: Jan 1 '08

re: run time error -2147467259(80004005)-


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


Expand|Select|Wrap|Line Numbers
  1. Public Function Fill() As Variant
  2.  
  3. 'Declarations
  4. Dim reccheck As ADODB.Recordset
  5. Dim fldcheck As ADODB.Field
  6.  
  7. 'Obtain a criterion for WHERE clause, and
  8. 'construct Select statement
  9.  
  10. Dim str As String
  11. str = Format(curdate.Value, "dd/mmm/yy")
  12. str = "select tslot2 from work_details where emp_id=" & Text13.Value & " and current_date = " & str & "; "
  13.  
  14. 'open the recordset
  15. Set reccheck = New ADODB.Recordset
  16. reccheck.Open str, CurrentProject.Connection
  17.  
  18. 'Loop through recordset until EOF
  19. Do While Not reccheck.EOF
  20.     Debug.Print reccheck!tslot2 & ";" & reccheck!emp_id & ";" & reccheck(str) 
  21.     reccheck.MoveNext
  22. Loop
  23.  
  24. 'Clean up objects and links
  25. reccheck.Close
  26. Set reccheck = Nothing
Reply


Similar Microsoft Access / VBA bytes