By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,488 Members | 2,545 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,488 IT Pros & Developers. It's quick & easy.

Type mismatch function returns array

Expert 100+
P: 218
Hi

I wanted to return a Variant array, which contains 2 integers and a double, from my function.
Expand|Select|Wrap|Line Numbers
  1. Public Function GroupGradeCount(GroupIdent As Integer, GradeIdent As Integer, ColNum As Integer) As Variant
  2. '**************************************************************************************************
  3. '******** Parameters:-
  4. '********     1 - AsGroup.AsGroupIdent
  5. '********     2 - GradeLooup.GLIdent
  6. '********     3 - Number of assessment column (Ass1 = 1 / Ass2 = 2, etc)
  7. '**************************************************************************************************
  8. On Error GoTo ErrorAll
  9.     Dim Res1 As Double
  10.     Dim Res2 As Double
  11.     Dim Res3 As Double
  12.     Dim retVar(3) As Double
  13.     Dim rstGrade As ADODB.Recordset
  14.     InSql = "SELECT Count(*) As Counter FROM AsGroup INNER JOIN" & vbCrLf
  15.     InSql = InSql & "Assessment ON AsGroup.AsGroupIdent = Assessment.AsGroupIdent INNER JOIN" & vbCrLf
  16.     InSql = InSql & "AsHead ON AsGroup.AsHeadIdent = AsHead.AsHeadIdent INNER JOIN" & vbCrLf
  17.     InSql = InSql & "GradeLooup ON AsHead.AG" & ColNum & " = GradeLooup.GradeSetIdent" & vbCrLf
  18.     InSql = InSql & "WHERE (" & GroupIdent & " = AsGroup.AsGroupIdent) AND (" & GradeIdent & " = GradeLooup.GLIdent)" & vbCrLf
  19.     InSql = InSql & "AND (Assessment.Ass" & ColNum & " = GradeLooup.GLAssessment)"
  20.     Set rstGrade = New ADODB.Recordset
  21.     rstGrade.Open InSql, CurrentProject.Connection
  22.     Res1 = rstGrade!Counter * 1#
  23.     rstGrade.Close
  24.     Set rstGrade = Nothing
  25.  
  26.     Res2 = DCount("Ass" & ColNum, "Assessment", "Assessment.AsGroupIdent = " & GroupIdent) * 1#
  27.     Res3 = 100# * (Res1 / Res2)
  28.     retVar(0) = Res1
  29.     retVar(1) = Res2
  30.     retVar(2) = Res3
  31.     GroupGradeCount = retVar()
  32. ExitAll:
  33.     Exit Function
  34. ErrorAll:
  35.     Error1 Err.Description, Err.Number, "Function", "GroupGradeCount", errModule
  36.     Resume ExitAll
  37. End Function
Jan 12 '07 #1
Share this Question
Share on Google+
1 Reply


NeoPa
Expert Mod 15k+
P: 31,186
Is this still Relevant Steve?
Would you like me to close this thread?
Jan 12 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.