Results 1 to 5 of 5

Thread: what's wrong with this function?

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2001
    Location
    new orleans
    Posts
    3

    what's wrong with this function?

    Public Function LastPaymentDate( Conn As ADODB.Connection, _
    AccountNumber As String) As Date
    Dim RS As ADODB.Recordset

    Set RS = Conn.Execute( _
    "SELECT * " _
    & "FROM AR " _
    & "WHERE AccountNumber = '" & AccountNumber & "' " _
    & "ORDER BY PostingDate DESC")
    LastPaymentDate = IIf(RS.EOF, 0, RS("PostingDate"))
    RS.Close
    Set RS = Nothing
    End Function

  2. #2
    Frenzied Member jjortiz's Avatar
    Join Date
    Mar 2001
    Location
    NYC
    Posts
    1,768
    Do you have the Conn object declared in the General declarations?

  3. #3
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    Re: what's wrong with this function?

    Originally posted by Angelle
    Public Function LastPaymentDate( Conn As ADODB.Connection, _
    AccountNumber As String) As Date
    Dim RS As ADODB.Recordset

    Set RS = Conn.Execute( _
    "SELECT * " _
    & "FROM AR " _
    & "WHERE AccountNumber = '" & AccountNumber & "' " _
    & "ORDER BY PostingDate DESC")
    LastPaymentDate = IIf(RS.EOF, 0, RS("PostingDate"))
    RS.Close
    Set RS = Nothing
    End Function
    Also, can you assign 0 to a date variable?

    .
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

  4. #4
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    Conn.Execute should be
    Conn.OpenRecordset
    Mark
    -------------------

  5. #5
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    or is it:

    Code:
    dim strSQL as string
    strSQL = "SELECT * " _ 
    & "FROM AR " _ 
    & "WHERE AccountNumber = '" & AccountNumber & "' " _ 
    & "ORDER BY PostingDate DESC"
    
    rs.Open strSQL, conn, adOpenKeyset, adLockOptimistic
    Mark
    -------------------

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