Results 1 to 9 of 9

Thread: [RESOLVED] Method 'Value' of Object 'Field' failed

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2005
    Posts
    307

    Resolved [RESOLVED] Method 'Value' of Object 'Field' failed

    Ive been looking and testing my code for hours and hours now and cant figure out whats wrong...
    i found out it's coz of rsx!DateReturned for some reason
    ive got this

    VB Code:
    1. Dim days as long
    2.  
    3. [COLOR=RoyalBlue]days = DateDiff("d", rsx!DateReturned, rsx!DateDueBack)[/COLOR]

    to get rsx i use
    VB Code:
    1. sstr = "Select * From Copies, Video, PriceGroup, Client, HireOut " & _
    2.             "Where Copies.CPVideoID = Video.VideoID " & _
    3.             "AND Video.VIDPGID = PriceGroup.PGID " & _
    4.             "AND HireOut.HRTapeID = Copies.TapeID " & _
    5.             "AND HireOut.HRClientID = Client.ClientID " & _
    6.             "AND HireOut.LateCharged = 'No' " & _
    7.             "AND Client.ClientID = " & acrit1

    my system date is set to dd/MM/yyyy format and in the database (access) ive set it to dd mmm yyyy hh:nn:ss.....every other query ive used involving dates and the above formats works fine, but for some reason im getting an error on this one....i have no empty fields in DateReturned, and DateReturned is only field in my entire database that is named that?

    Any ideas? i get the error on the blue line

  2. #2
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Method 'Value' of Object 'Field' failed

    try this....
    VB Code:
    1. If isDate(rsx!DateReturned) Then
    2.     days = DateDiff("d", Cdate(rsx!DateReturned), Cdate(rsx!DateDueBack))
    3. Else
    4.     Msgbox rsx!DateReturned
    5. End If
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    May 2005
    Posts
    307

    Re: Method 'Value' of Object 'Field' failed

    ok it says now Application-defined or object-defined error and it highlights Msgbox rsx!DateReturned

  4. #4
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Method 'Value' of Object 'Field' failed

    ok, post more of your code.. it sounds as if rsx isnt even declared...or set to a recordset.
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  5. #5
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    Re: Method 'Value' of Object 'Field' failed

    What if you don't include the field in the msgbox statement. Try just a literal and see if it works.

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    May 2005
    Posts
    307

    Re: Method 'Value' of Object 'Field' failed

    VB Code:
    1. Dim rsx As New ADODB.Recordset
    2.  
    3. Set rsx = Datacc.GetHireOutCopies2(Text2.Text)

    VB Code:
    1. Public Function GetHireOutCopies2(ByVal acrit1 As Long) As ADODB.Recordset
    2. Dim rsx As New ADODB.Recordset
    3. Dim sstr As String
    4.  
    5. rsx.CursorLocation = adUseClient
    6.  
    7. sstr = "Code given at post # 1
    8.  
    9. rsx.Open sstr, DB
    10.  
    11. Set GetHireOutCopies2 = rsx
    12.  
    13. Set rsx = Nothing
    14.  
    15. End Function

  7. #7
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Method 'Value' of Object 'Field' failed

    for fun, change the rsx in this to just rs.
    u are already using rsx, even though I dont think it should interfere...
    just curious
    VB Code:
    1. Public Function GetHireOutCopies2(ByVal acrit1 As Long) As ADODB.Recordset
    2. Dim rs As New ADODB.Recordset
    3. Dim sstr As String
    4.  
    5. rs.CursorLocation = adUseClient
    6.  
    7. sstr = "Code given at post # 1
    8.  
    9. rs.Open sstr, DB
    10.  
    11. Set GetHireOutCopies2 = rs
    12.  
    13. Set rs = Nothing
    14.  
    15. End Function
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    May 2005
    Posts
    307

    Re: Method 'Value' of Object 'Field' failed

    i think i fixed it...i decided to copy one of the dates from the DateDueBack field into all the DateReturned fields, and it goes through the code without problem now....maybe one of the values was corrupt or something...

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    May 2005
    Posts
    307

    Re: [RESOLVED] Method 'Value' of Object 'Field' failed

    thanx for the help

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width