Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

Error 2495 running code

Discussion in 'Information Technology' started by Mike, Jul 28, 2006.

  1. Mike

    Mike
    Expand Collapse
    Guest

    My code is attached. When I run this real-time, I have no problems.
    When I attempt to call it using a
    DoCmd.OpenFunction(updARBals(varDate)) it loops through the code until
    the last record, where I then get the message Error 2495: Action or
    method requires a table name argument.

    The other functions (referred to in the below code) are properly
    returning data into this main function. I will be running this behind
    the scenes as prep work to build reports.

    It's got to be something simple - what am I missing?

    TIA, Mike

    ++++++++++++++++++++++++

    Option Compare Database
    Option Explicit
    ++++++++++++++++++++++++
    Public Function updARBals(DateLimiter)
    Dim rs As New ADODB.Recordset
    Dim sql As String

    ' Function loops through existing dates in Period Balances table up to
    limiter
    ' For each loop, a LH query is run to calculate the fee AR balance and
    updates the table with the month's information

    sql = "Select * from PeriodBalances WHERE (PeriodEndDate <= #" &
    [DateLimiter] & "#)"
    DoCmd.SetWarnings False
    rs.Open sql, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
    rs.MoveFirst
    Do While Not rs.EOF
    Dim Billed, Recd, FeeAR As Currency
    Billed = LHAmount(rs("PeriodEndDate"), "B") ' calls external
    function to obtain billed data as of date
    Recd = LHAmount(rs("PeriodEndDate"), "C") ' calls external function
    to obtain billed data as of date
    FeeAR = Billed - Recd
    DoCmd.RunSQL ("UPDATE PeriodBalances SET PeriodARBalance = " &
    FeeAR & " WHERE (PeriodEndDate = # " & rs("PeriodEndDate") & " #)")
    rs.MoveNext
    Loop
    DoCmd.SetWarnings True
    rs.Close
    Set rs = Nothing
    End Function
    ++++++++++++++++++++++++++
     
  2. Loading...


  3. Chris

    Chris
    Expand Collapse
    Guest

    "Mike" wrote:

    > My code is attached. When I run this real-time, I have no problems.
    > When I attempt to call it using a
    > DoCmd.OpenFunction(updARBals(varDate)) it loops through the code until
    > the last record, where I then get the message Error 2495: Action or
    > method requires a table name argument.
    >
    > The other functions (referred to in the below code) are properly
    > returning data into this main function. I will be running this behind
    > the scenes as prep work to build reports.
    >
    > It's got to be something simple - what am I missing?
    >
    > TIA, Mike
    >
    > ++++++++++++++++++++++++
    >
    > Option Compare Database
    > Option Explicit
    > ++++++++++++++++++++++++
    > Public Function updARBals(DateLimiter)
    > Dim rs As New ADODB.Recordset
    > Dim sql As String
    >
    > ' Function loops through existing dates in Period Balances table up to
    > limiter
    > ' For each loop, a LH query is run to calculate the fee AR balance and
    > updates the table with the month's information
    >
    > sql = "Select * from PeriodBalances WHERE (PeriodEndDate <= #" &
    > [DateLimiter] & "#)"
    > DoCmd.SetWarnings False
    > rs.Open sql, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
    > rs.MoveFirst
    > Do While Not rs.EOF
    > Dim Billed, Recd, FeeAR As Currency
    > Billed = LHAmount(rs("PeriodEndDate"), "B") ' calls external
    > function to obtain billed data as of date
    > Recd = LHAmount(rs("PeriodEndDate"), "C") ' calls external function
    > to obtain billed data as of date
    > FeeAR = Billed - Recd
    > DoCmd.RunSQL ("UPDATE PeriodBalances SET PeriodARBalance = " &
    > FeeAR & " WHERE (PeriodEndDate = # " & rs("PeriodEndDate") & " #)")
    > rs.MoveNext
    > Loop
    > DoCmd.SetWarnings True
    > rs.Close
    > Set rs = Nothing
    > End Function
    > ++++++++++++++++++++++++++
    >
    >
     
  4. Chris

    Chris
    Expand Collapse
    Guest

    Thanks this helped me out alot.

    "Mike" wrote:

    > My code is attached. When I run this real-time, I have no problems.
    > When I attempt to call it using a
    > DoCmd.OpenFunction(updARBals(varDate)) it loops through the code until
    > the last record, where I then get the message Error 2495: Action or
    > method requires a table name argument.
    >
    > The other functions (referred to in the below code) are properly
    > returning data into this main function. I will be running this behind
    > the scenes as prep work to build reports.
    >
    > It's got to be something simple - what am I missing?
    >
    > TIA, Mike
    >
    > ++++++++++++++++++++++++
    >
    > Option Compare Database
    > Option Explicit
    > ++++++++++++++++++++++++
    > Public Function updARBals(DateLimiter)
    > Dim rs As New ADODB.Recordset
    > Dim sql As String
    >
    > ' Function loops through existing dates in Period Balances table up to
    > limiter
    > ' For each loop, a LH query is run to calculate the fee AR balance and
    > updates the table with the month's information
    >
    > sql = "Select * from PeriodBalances WHERE (PeriodEndDate <= #" &
    > [DateLimiter] & "#)"
    > DoCmd.SetWarnings False
    > rs.Open sql, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
    > rs.MoveFirst
    > Do While Not rs.EOF
    > Dim Billed, Recd, FeeAR As Currency
    > Billed = LHAmount(rs("PeriodEndDate"), "B") ' calls external
    > function to obtain billed data as of date
    > Recd = LHAmount(rs("PeriodEndDate"), "C") ' calls external function
    > to obtain billed data as of date
    > FeeAR = Billed - Recd
    > DoCmd.RunSQL ("UPDATE PeriodBalances SET PeriodARBalance = " &
    > FeeAR & " WHERE (PeriodEndDate = # " & rs("PeriodEndDate") & " #)")
    > rs.MoveNext
    > Loop
    > DoCmd.SetWarnings True
    > rs.Close
    > Set rs = Nothing
    > End Function
    > ++++++++++++++++++++++++++
    >
    >
     

Share This Page