473,320 Members | 1,881 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Type mismatch function returns array

218 Expert 100+
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
1 2743
NeoPa
32,556 Expert Mod 16PB
Is this still Relevant Steve?
Would you like me to close this thread?
Jan 12 '07 #2

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

Similar topics

4
by: Laura | last post by:
Help. Below is my code. Getting Type mismatch error on the noted line. I'm trying to send an array (aryNewD) with 4 columns and x rows to a function to save all the array info into a SQL Server...
4
by: leslie_tighe | last post by:
Hello, I have a method on a com+ object that is returning an array of objects. I know the array is popluated as calls to check the ubound and lbound show valid values. However, any calls to...
3
by: martlaco1 | last post by:
Trying to fix a query that (I thought) had worked once upon a time, and I keep getting a Data Type Mismatch error whenever I enter any criteria for an expression using a Mid function. Without the...
2
by: leo2100 | last post by:
Hi, I need help with this program. The program is supposed to take a text file and identify the words in it, then it should print them and count how many times a word is repeated. At first main...
2
by: igor.barbaric | last post by:
Hello! I have created a very simple query like this: SELECT Tasks.Name, DurationHrs(,) AS Duration FROM Tasks INNER JOIN Log ON Tasks.TaskID=Log.TaskID; The above query works fine....
12
by: arnuld | last post by:
this is exercise 2-3 from the mentioned section. i have created a solution for it but i see errors and i tried to correct them but still they are there and mostly are out of my head: ...
19
by: Lysander | last post by:
I have written a query that takes three integers representing day,month and year, forms a date from them and compares this date to the date the record was entered and returns any records where the...
22
by: Ruben | last post by:
Why would a method that is defined to return a reference such as with the operator overload of , operator, href& operator(int index){ return _array; } not cause a type mismatch compiler...
10
by: lasmith329 | last post by:
I've never posted a question on any site before, but after racking my head over this hurdle for days, I've caved. I'm working on a program that creates a kml file and exports it to Google Earth. In...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.