Results 1 to 3 of 3
  1. #1
    carl g.
    Guest

    Type Declarations and Collections

    Hi All,

    I'm wondering if anyone out there can help me.
    I'm trying to add a user defined type to a collection (in MS Access 97), but keep getting a "Byref argument type mismatch" error when I try to compile. Here is what I think is the relevant code:

    Option Compare Database
    Option Explicit

    Dim AccColl As Collection
    Type LTRowCollect
    dblYTDU As Double
    dblYTDR As Double
    dblYTDF As Double
    dblYTDB As Double
    tmpKEY As String
    End Type

    Sub LOANTUpdate()

    Dim LTRows As LTRowCollect
    Dim rstSQL as DAO.Recordset
    Set AccColl = New Collection

    'some sql recordset stuff in here

    Do Until rstSQL.EOF

    LTRows.tmpKEY = rstSQL![tmpKEY]
    LTRows.dblYTDU = rstSQL![YTD_PL_Unrealized]
    LTRows.dblYTDR = rstSQL![YTD_PL_Realized]
    LTRows.dblYTDF = rstSQL![YTD_PL_Tr_Fees]
    LTRows.dblYTDB = rstSQL![YTD_PL_Broker_Comm]

    AccColl.Add Item:=LTRows, key:=LTRows.tmpKEY

    rstSQL.MoveNext
    Loop

    This worked well until I moved from declaring the elements of the type in a class module to the UDF Type statement. (It seemed a little bit wasteful to have a whole class module just for 4 variables)

    Regards,

    Carl

  2. #2
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    The Netherlands
    Posts
    216
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Type Declarations and Collections

    Hi,

    I am not sure, but try following:
    Force the values passed to the collection to be double.
    Example:

    LTRows.dblYTDR = cdbl(rstSQL![YTD_PL_Realized])

  3. #3
    carl g.
    Guest

    Re: Type Declarations and Collections

    Thanks Bart, but that doesn't seem to work.

    I should have said before - when the error message is displayed the "LTRows" portion of the AccColl.Add Item:=LTRows is highlighted.

    Regards,

    Carl

Posting Permissions

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