Error 2495 running code

M

Mike

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
++++++++++++++++++++++++++
 
C

Chris

Mike said:
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
++++++++++++++++++++++++++
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top