Results 1 to 2 of 2

Thread: Results of functions in my code donít appear in my output table

  1. #1

    Results of functions in my code donít appear in my output table

    Hi there, I've got a function and within it are embedded 2 other functions (CalcAsin2 and CalcGDD), which are called from within the main function. The code seems to run (i.e., no error messages, and the output table that I create is made and populated with most of the values I want) but the two columns that should be filled with values generated by my Functions CalcAsin2 and CalcGDD are populated with empty cells instead. Any help on this matter would be greatly appreciated! Thanks, -Tiffany The code is: Option Compare Database Function CalculateHeatUnits() Dim db As Database Dim tdfNew As TableDef Dim rin, rout, T_mean, T_range, theta, Pmon, GDD, Asin2 ofilename = "growing_degree_day_test2" Set db = CurrentDb() For i = 0 To db.TableDefs.Count - 1 ' Delete table If db.TableDefs(i).Name = ofilename Then DoCmd.DeleteObject A_TABLE, ofilename Exit For End If Next Set tdfNew = db.CreateTableDef(ofilename) With tdfNew .Fields.Append .CreateField("grid", dbLong) .Fields.Append .CreateField("month", dbbyte) .Fields.Append .CreateField("GDD_test", dbSingle) .Fields.Append .CreateField("theta_test", dbSingle) .Fields.Append .CreateField("asin_theta", dbSingle) .Fields.Append .CreateField("Tm", dbSingle) .Fields.Append .CreateField("Tr", dbSingle) db.TableDefs.Append tdfNew End With Set rinwd = db.OpenRecordset("GDD_test_input2") Set rout = db.OpenRecordset(ofilename) T_mean = ( + rinwd.maxt) / 2 T_range = (rinwd.maxt - / 2 theta = (rinwd.baseT - T_mean) / T_range rinwd.MoveFirst Do Until rinwd.EOF Call CalcAsin2(theta) GDD2 = CalcGDD(rinwd.maxt,, T_mean, rinwd.baseT, Asin2) milf = theta gilf = GDD2 cilf = theta dilf = Asin2 eilf = T_mean filf = T_range rout.AddNew rout![grid] = rinwd.deg05 rout![Month] = rinwd.Month rout![GDD_test] = gilf rout![theta_test] = cilf rout![asin_theta] = dilf rout![Tm] = eilf rout![Tr] = filf rout.Update rinwd.MoveNext Loop rinwd.Close: rout.Close End Function Function CalcAsin2(pDiddy) Dim Asin2 As Double Asin2 = Atn(pDiddy / Sqr(-pDiddy * pDiddy + 1)) End Function Function CalcGDD(T_x, T_min, T_m, T_thresh, Asin2) Dim GDD As Double cow_pi = 3.14159265 GDD = 0 If Max_T > T_thresh And T_thresh > Min_T Then GDD = (1 / cow_pi) * ((T_m - ThreshT) * ((cow_pi / 2) - Asin2(theta)) + (T_r * Cos(Asin2(theta)))) ElseIf T_thresh = T_x Then GDD = 0 End If End Function



  2. #2
    VBAX Guru
    Mar 2005

Posting Permissions

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