Timtropolis
Registered User.
- Local time
- Today, 14:30
- Joined
- Jun 17, 2004
- Messages
- 84
Greetings all.
First, wasn't sure whether to post this here or under queries so I'm posting here so sorry in adavance if its the wrong area.
Ok, that being said, here's my problem. In a application that I'm developing an Access 2010, I have created a query which has a column that calls a function and passes two arguments to the function.
Net_Accrued_Income_Amt: Get_NetAccruedIncomeAmt([t_fps_fd].[fd_id],[t_fps_fd].[csh_calc_mthd_id])
My custom function then takes these items and uses the first argument as part of a where clause to in a recordset.
The second is used as a flag in a Select statement. See the code below.
What is happening is that I'm getting a #NUM! error in my column, the code isn't even executing as i'm not able to trap anything. I've verified that the two arguments being passed are in the correct datatype.
I have also ran the function on its own (no arguments passed, hard coded values I needed) and it worked fine, so i'm assuming I'm doing something wrong with regards to passing arguments, etc.
Any help would be most welcome.
TIA,
Tim
First, wasn't sure whether to post this here or under queries so I'm posting here so sorry in adavance if its the wrong area.
Ok, that being said, here's my problem. In a application that I'm developing an Access 2010, I have created a query which has a column that calls a function and passes two arguments to the function.
Net_Accrued_Income_Amt: Get_NetAccruedIncomeAmt([t_fps_fd].[fd_id],[t_fps_fd].[csh_calc_mthd_id])
My custom function then takes these items and uses the first argument as part of a where clause to in a recordset.
The second is used as a flag in a Select statement. See the code below.
Code:
Public Function Get_NetAccruedIncomeAmt(ByVal FUND_id As Integer, ByVal csh_calc_mthd_id As Integer)
On Error GoTo MyFunctioinMessage_Error
Dim dbs3 As DAO.Database
Dim rst3 As DAO.Recordset
Dim strSQL As String
Dim Ctr As Integer
Dim x, y As Double
Set dbs3 = CurrentDb
strSQL = "SELECT t_fps_fd.*, t_fps_fd_val.* FROM t_fps_fd INNER JOIN t_fps_fd_val ON t_fps_fd.fd_id = t_fps_fd_val.fd_id"
strSQL = strSQL = "WHERE t_fps_fd.fd_id = FUND_ID" '<--- 1st argument
Set rst3 = dbs3.OpenRecordset(strSQL, dbOpenDynaset)
rst3.MoveFirst
Do Until rst3.EOF
With rst3
Select Case csh_calc_mthd_id '<--- 2nd argument
Case Is = 1
x = (!prr_udstr_incm_am + !dstr_incm_am + !tot_incm_am) - !tot_xpns_am
If !eqal_csh_am_usg_fl = 0 Then
x = x + !eqal_csh_am
Get_NetAccruedIncomeAmt = x
Else
Get_NetAccruedIncomeAmt = x
End If
Case Is = 2
x = !csh_fgn_ccy_am + !mm_insm_am + !acrl_incm_am + !net_stl_pend_trd_am
x = x + !sum_cptl_ast_sld_prch_am + !othr_ast_agr_am + !liab_agr_am
Get_NetAccruedIncomeAmt = x
..........
What is happening is that I'm getting a #NUM! error in my column, the code isn't even executing as i'm not able to trap anything. I've verified that the two arguments being passed are in the correct datatype.
I have also ran the function on its own (no arguments passed, hard coded values I needed) and it worked fine, so i'm assuming I'm doing something wrong with regards to passing arguments, etc.
Any help would be most welcome.
TIA,
Tim
Last edited: