How do you?

Tawcan

Registered User.
Local time
Today, 16:08
Joined
Mar 19, 2003
Messages
58
Right now I want to create a new table on my database. This new table is used for the failed course report. To create this table the database needs to go into each student's record and look for grade that's lower than 50%.

I'm not too good with coding, so how would I be able to do that?

Logical steps...

1. Have a sub function to create these new tables

2. Create a new table with fields "course" and "grade"

3. Go into the existing student record table and pull anything that's below 50%.

4. The fail course report is then linked to this new table

Right idea? Right now I can't seem to come up with codes for step 2. Any idea?

Thanx. :)
 
Why create a new table that will have redundant data. Just build a query off the Student information that you already have and use this for the report.

Query would contain Student, Course, %

Criteria would be <=.5 for the %.

Does that help?
 
Yep thanx. :D

Couple more quick questions...

Right now I have bunch student records and new ones will be added... what can I do so this quiery would get created automatically?

Also, some of the grades are either P or F. So for the criteria do I do <=.5 and != 'P' ?

Thanx.

:D
 
Not sure what you mean by run automatically. once you create the query you can run it anytime. If you have a form and what to create a command button, the code for it would be

Docmd.OpenQuery, "NameofQuery"

The criteria would be >=.50 or F

This would give you all the % equal to or below 50% or where the Grade is F (Fail)

HTH
 
Yep I figured that out. :)

For some reason it was displaying grade that's 100% so I had to do <> 100 :p

What I meant by automatically...

I can't afford creating quiery for each student. We're talking like 200+ students here and this number grows every year.

Is it possible to have some sort of code behind the button on a form (like view Fail Courses button) so this kind of quiery will be created automatically when the button is pressed? I know you can do it with table, but I don't know about quieiry.

Thanx. :)
 
Can you send a copy of the database to me. I'll see what I can do for you.

If the database is to big to be sent to a hotmail account send me a message and I'll give you a different account.
 
jfgambit said:
Can you send a copy of the database to me. I'll see what I can do for you.

If the database is to big to be sent to a hotmail account send me a message and I'll give you a different account.

It's 44MB big. :p

Though not the same this is kinda what I'm talking about:

'VIEW AU REPORT button.
'This function calls the function AU_query.

Private Sub Label124_Click()
On Error GoTo ErrorHandler

If (IsNull(Me!Box2)) Then
MsgBox ("Please first select a student by clicking on GET STUDENT or browsing through the STUDENT LIST.")
Exit Sub
End If
AU_query
DoCmd.OpenReport "AU REPORT", acViewPreview
Exit Sub

ErrorHandler:
MsgBox Error(Err)
Exit Sub

End Sub

'This will make a table to get the AU's from the appropriate AU table.
'This table is then used to generate a student's AU report.

Private Sub AU_query()
On Error GoTo ErrorHandler
Dim qdf1 As QueryDef, tbl3 As DAO.TableDef, table As DAO.Recordset
Dim strSQL2 As String, AUREPORT As String
tableName = Forms![INDIVIDUAL APR]!Box2
Set db = CurrentDb()
If ObjectExists(acTable, "AU REPORT") Then DoCmd.DeleteObject acTable, "AU REPORT"

Set tbl = db.OpenRecordset("SELECT * FROM [" & tableName & "];")

'Create new table.
Set tbl3 = db.CreateTableDef("AU REPORT")
With tbl3
.Fields.Append .CreateField("REQ COURSE", dbText)
.Fields.Append .CreateField("ACT COURSE", dbText)
.Fields.Append .CreateField("OPTION", dbText)
.Fields.Append .CreateField("CREDITS", dbText)
.Fields.Append .CreateField("SESSION", dbText)
.Fields.Append .CreateField("YEAR", dbText)
.Fields.Append .CreateField("MATH AU", dbText)
.Fields.Append .CreateField("BAS SCI AU", dbText)
.Fields.Append .CreateField("COMP STUD AU", dbText)
.Fields.Append .CreateField("ENG DES AU", dbText)
.Fields.Append .CreateField("ENG SCI AU", dbText)

End With

db.TableDefs.Append tbl3
Set table = db.OpenRecordset("AU REPORT", dbOpenTable)
If (tbl.RecordCount = 0) Then

Exit Sub
Else

tbl.MoveFirst
Do Until tbl.EOF
table.AddNew
table![REQ COURSE] = tbl![REQ COURSE]
table![ACT COURSE] = tbl![ACT COURSE]
table![OPTION] = tbl![OPTION]
table![CREDITS] = tbl![ACT CREDITS]
table![SESSION] = tbl![SESSION]
table![YEAR] = tbl![YEAR]
calYear = session_edit(tbl![SESSION])
If (Not (calYear = "20" Or calYear = "19")) Then

Set Autable = db.OpenRecordset("SELECT * FROM [AU " & calYear & "];")
checkAU = "[COURSE] = '" & tbl![ACT COURSE] & "'"
Autable.FindFirst checkAU
If (Not (Autable.NoMatch)) Then

table![MATH AU] = Autable![MATH AU]
table![BAS SCI AU] = Autable![BAS SCI AU]
table![COMP STUD AU] = Autable![COMP STUD AU]
table![ENG DES AU] = Autable![ENG DES AU]
table![ENG SCI AU] = Autable![ENG SCI AU]

End If
End If
table.Update
tbl.MoveNext
Loop
End If

Exit Sub
ErrorHandler:
MsgBox Error(Err)
If ObjectExists(acTable, "AU REPORT") Then DoCmd.DeleteObject acTable, "AU REPORT"
Exit Sub

End Sub


As you can see, it creates a new table when View AU Report button is created. Just wondering if you can do the same thing for quiery. :)
 
Yes, you really don't want to create duplicated data in the db. First off, run a Compact and Repair on the database that should help to reduce the size.

Then zip it and tell me how big the zipped file is.
 
Got it down to 340 KB zipped. What's your email address? PM me if you don't want other ppl to see it. :)

I think query will solve most of the problems I'm having (in other word, stuff I'm trying to do). :D
 

Users who are viewing this thread

Back
Top Bottom