Thanks for looking at this. What I'm trying to do is, from a spreadsheet
that I import from excel of student transcript data, ultimately create
transcripts. The table [Mark] field has values from 0-100, P or F (and some
other text values). I need to ultimately create a report for each student
that changes the 0-100 score to a 4.0 scale using the following calculation
(from 0-64 to 0.5, from 65-94 using the formula [Mark-55/10], from 95-100 to
4.0, and all text fields to stay as they are). Then I want the report to
calculate the average of the new grades (from the 4.0 scale), excluding any
text values.
There are many other fields that need to go on the report, so I apologize
for the excess info from the query (SQL below). But this is it:
SELECT tbl_bios.ACTIVE, tbl_allstudentsallgrades_hsst.StudentID,
tbl_allstudentsallgrades_hsst.LastName,
tbl_allstudentsallgrades_hsst.FirstName, tbl_allstudentsallgrades_hsst.Year,
tbl_allstudentsallgrades_hsst.Term, tbl_allstudentsallgrades_hsst.Course,
DLookUp("Department","tbl_CourseCodes_departments","CourseCodes='" & [Course]
& "'") AS DEPT, tbl_department_requiredcredits.Required_Credits,
tbl_allstudentsallgrades_hsst.Title, tbl_allstudentsallgrades_hsst.Mark,
tbl_allstudentsallgrades_hsst.Credits, DetermineResult([Mark]) AS Vangrade,
[FirstName] & " " & [LastName] AS FullName, tbl_bios.ADVISOR, tbl_bios.DOB,
tbl_bios.SEX, tbl_bios.ADDRESS, tbl_bios.CITY, tbl_bios.STATE, tbl_bios.ZIP,
tbl_bios.GRADE, tbl_bios.PARENT1, tbl_bios.PHONE1, [ADDRESS] & ", " & [CITY]
& ", " & [STATE] & " " & [ZIP] AS FnlAddress, [PARENT1] & ", " & [PHONE1] AS
FullContact, tbl_bios.COHORT, qry_finalGPA.AvgOfMark, qry_finalGPA.MarktoGPA,
tbl_bios.SPEDSTS, tbl_bios.ETHNICITY, tbl_bios.LOWEST_THIRD_CITYWIDE,
tbl_bios.LOWEST_THIRD_ELA_SCHOOL, tbl_bios.LOWEST_THIRD_MATH_SCHOOL,
tbl_allstudentsallgrades_hsst.School
FROM tbl_bios INNER JOIN ((qry_finalGPA INNER JOIN
tbl_allstudentsallgrades_hsst ON
qry_finalGPA.StudentID=tbl_allstudentsallgrades_hsst.StudentID) INNER JOIN
(tbl_coursecodes_departments INNER JOIN tbl_department_requiredcredits ON
tbl_coursecodes_departments.Department=tbl_department_requiredcredits.DepartmentList)
ON
tbl_allstudentsallgrades_hsst.Course=tbl_coursecodes_departments.CourseCodes)
ON tbl_bios.OSIS=tbl_allstudentsallgrades_hsst.StudentID
GROUP BY tbl_bios.ACTIVE, tbl_allstudentsallgrades_hsst.StudentID,
tbl_allstudentsallgrades_hsst.LastName,
tbl_allstudentsallgrades_hsst.FirstName, tbl_allstudentsallgrades_hsst.Year,
tbl_allstudentsallgrades_hsst.Term, tbl_allstudentsallgrades_hsst.Course,
DLookUp("Department","tbl_CourseCodes_departments","CourseCodes='" & [Course]
& "'"), tbl_department_requiredcredits.Required_Credits,
tbl_allstudentsallgrades_hsst.Title, tbl_allstudentsallgrades_hsst.Mark,
tbl_allstudentsallgrades_hsst.Credits, ([Mark]-55)/10, [FirstName] & " " &
[LastName], tbl_bios.ADVISOR, tbl_bios.DOB, tbl_bios.SEX, tbl_bios.ADDRESS,
tbl_bios.CITY, tbl_bios.STATE, tbl_bios.ZIP, tbl_bios.GRADE,
tbl_bios.PARENT1, tbl_bios.PHONE1, [ADDRESS] & ", " & [CITY] & ", " & [STATE]
& " " & [ZIP], [PARENT1] & ", " & [PHONE1], tbl_bios.COHORT,
qry_finalGPA.AvgOfMark, qry_finalGPA.MarktoGPA, tbl_bios.SPEDSTS,
tbl_bios.ETHNICITY, tbl_bios.LOWEST_THIRD_CITYWIDE,
tbl_bios.LOWEST_THIRD_ELA_SCHOOL, tbl_bios.LOWEST_THIRD_MATH_SCHOOL,
tbl_allstudentsallgrades_hsst.School
HAVING (((tbl_allstudentsallgrades_hsst.LastName) Like [Enter a Last Name] &
"*") AND ((tbl_bios.ADVISOR) Like [What Advisor Are You Looking For?] & "*")
AND ((tbl_bios.GRADE) Like [What Grade Are You Looking For?] & "*") AND
((tbl_bios.COHORT) Like [What Cohort Are You Looking For?] & "*"));
The DetermineResult[Mark] is the module that changes the numerical values
from 0-100 to the appropriate 4.0 scale. The code for that is:
Option Compare Database
Option Explicit
Public Function DetermineResult(Mark As Variant) As Variant
On Error Resume Next
If Len(Mark & "") > 0 Then
Select Case Mark
Case "P", "F"
DetermineResult = Mark
Case "0"
DetermineResult = 0.5
Case IsNumeric(Mark) = True
Mark = CCur(Mark)
Select Case Mark
Case 0 To 64
DetermineResult = 0.5
Case 65 To 95
DetermineResult = Format(([Mark] - 55) / 10, "0.0")
Case 96 To 100
DetermineResult = Format(4, "0.0")
Case Else
DetermineResult = "Out of range."
End Select
Case Else
DetermineResult = "Out of range."
End Select
End If
End Function
I'm having a few problems, all depending on the approach to solving the
problem. It seems to me that one solution would be to import a purely text
file so that all the non-numerical values show up. (If the Mark field is set
to number, the non-numerical values do not appear). However, this creates
the problem that now the calculations do not work on the numerical values
(because they are designated as text). So I suppose the question is, how can
I make the query only deal with the numerical items form the table and treat
them as such, even though on the table they are demarcated as text. (note:
the module will not work if the mark field is set to number).
Thanks again.
--
--vanguardaccessman
Rob Parker said:
Please post the SQL of your query, and the code for the custom function
(which is what I assume you mean when you say "module")you are using.
Without this, no-one will be able to help effectively.
Rob
Thanks for your reply. I think that I did a poor job of thinking through
the
issue and explaining, as the more I look at my database the bigger the
problem I think this is...
First, I have a table with the following fields:
[ID]---[Mark]
[Mark] needs to be a text field because it can either be a number (from
1-100) or letter (P or F). It is being imported from an outside excel
spreadsheet (which needs to happen regularly), and if it is numerical the
table excludes the P's or F's.
The query that I'm running refers to a module. It turns the mark column
into a different scale (from 0-64 to 0,5, from 65-95 it applies the
formula
([mark]-55)/10, from 96-100 to 4.0, and P's and F's stay as are).
I see that I'm going to have to redesign elements of my database, which is
okay. But what I need to be able to do is calculate on the text field in
both queries and reports. Is that possible? I would like it to ignore
the
P's and F's, treat the numbers (from 0.5 to 4.0) that result from the
module
as numbers, then calculate averages, for example.
Any help would be greatly appreciated.
--
--vanguardaccessman
:
Hi
This will not cause any problems
SELECT TableName.ID, TableName.Mark
FROM TableName;
Do you have anything else in the query that could make the error
--
Wayne
Manchester, England.
:
I have a table with the following fields:
[ID]---[Mark]
The [Mark] field is set as text, and can have values that are numerical
(from 0-100) or text (P or F).
I have a query that is built of this table with the same two fields.
However, when I run it, the following error occurs:
"The expression is typed incorrectly, or is too complex to be
evaluated.
For example, a numeric expression may contain too many complicated
elements.
Try simplifying the expression by assigning parts of the expression to
variables."
Any idea of what is wrong?