V
vavroom
I thought I knew how to proceed, but I've wasted nearly the entire day
and I realise that I'm not even sure I'm barking up the right tree! I
hope some of you might be able to enlighten me
What I want to do, in a nutshell, is to calculate how many exam papers
to print, based on a number of factor (including how many students are
sitting the exam and the location of the exam).
I am working with an inherited poorly designed database to start, and
I have *no* control over that. I have what I have, and I have to work
with it, unfortunately.
In one table (Examsbm), I have a list of paper offerings, and fields
for how many copies to print.
In another table(Studpervenue), I have a list of all students sitting
exams, and their location.
There's basically 4 locations. PN, Wel, Alb, and Extramural.
Extramural is complicated by the fact that I have nearly 75 venues.
So, if the location is PN, Wel or Alb, there is nothing in the venue
field. If it's Extramural, there's a venue reference.
Using a query with Group By on the student's table, I was able to
calculate how many students are sitting at each location/venue.
I based a form on that query, and using the code at the bottom (sorry
for the long, somewhat messy code), I am able to determine how many
papers need to be printed for each paper offering, broken down by
venue.
Which is fine, however, the next step I need to do is to compile the
information from all the venues into one to determine the number of
papers to print for the Extramural location. Then I need to write
that information to the Examsbm table, as Studpervenue is a temporary
table.
I have a feeling I'm going about this the wrong way. If anyone could
help and point a kind finger in the right direction, I would greatly
appreciate it.
Thanks
===
Note that the code below is really only just to apply the right
calculations, which I don't feel would have worked in a query, what
with the resulting nested if/then, etc.
Private Sub Form_Current()
Dim sExtra As String
sExtra = (Me.paper_line Like "*E*" Or Me.paper_line Like "*B*")
'Calculates the number of extra copies for extramural papers
'Puts the value in sECopies
Dim sECopies As String
Dim stEAlb As String
If Me.exam_centre Like "1010*" Then
If Me.TotalStuds >= 1 And Me.TotalStuds <= 4 Then
sECopies = "5"
Me.txtEMExtras = "5"
ElseIf Me.TotalStuds >= 5 And Me.TotalStuds <= 9 Then
sECopies = "5"
Me.txtEMExtras = "10"
ElseIf Me.TotalStuds >= 10 And Me.TotalStuds <= 14 Then
sECopies = "10"
Me.txtEMExtras = "15"
ElseIf Me.TotalStuds >= 15 Then
sECopies = "10"
Me.txtEMExtras = "20"
End If
Else
If Me.TotalStuds >= 1 And Me.TotalStuds <= 4 Then
sECopies = "2"
Me.txtEMExtras = "5"
ElseIf Me.TotalStuds >= 5 And Me.TotalStuds <= 9 Then
sECopies = "3"
Me.txtEMExtras = "10"
ElseIf Me.TotalStuds >= 10 And Me.TotalStuds <= 14 Then
sECopies = "4"
Me.txtEMExtras = "15"
ElseIf Me.TotalStuds >= 15 Then
sECopies = "5"
Me.txtEMExtras = "20"
End If
End If
'Calculates the number of extra copies for internal papers
'Puts the value in sICopies
Dim sICopies As String
Dim stPN As String
Dim stAlb As String
Dim stWel As String
If Me.paper_line Like "*I 4*" Or Me.paper_line Like "*I2 4*" Or
Me.paper_line Like "*I 15*" Or Me.paper_line Like "*I 20*" Then
stWel = "0"
stAlb = "0"
If Me.TotalStuds <= 5 Then
stPN = "10"
ElseIf Me.TotalStuds >= 6 And Me.TotalStuds <= 30 Then
stPN = "15"
ElseIf Me.TotalStuds >= 31 And Me.TotalStuds <= 60 Then
stPN = "20"
ElseIf Me.TotalStuds >= 61 And Me.TotalStuds <= 120 Then
stPN = "25"
ElseIf Me.TotalStuds >= 121 And Me.TotalStuds <= 180 Then
stPN = "30"
ElseIf Me.TotalStuds >= 181 And Me.TotalStuds <= 240 Then
stPN = "35"
ElseIf Me.TotalStuds >= 241 And Me.TotalStuds <= 300 Then
stPN = "40"
ElseIf Me.TotalStuds >= 301 And Me.TotalStuds <= 360 Then
stPN = "45"
ElseIf Me.TotalStuds >= 361 And Me.TotalStuds <= 420 Then
stPN = "50"
ElseIf Me.TotalStuds >= 421 And Me.TotalStuds <= 480 Then
stPN = "55"
ElseIf Me.TotalStuds >= 481 Then
stPN = "60"
End If
ElseIf Me.paper_line Like "*I 10*" Then
stPN = "0"
stWel = "0"
'if the paper is internal Albany
If Me.TotalStuds <= 60 Then
stAlb = "10"
ElseIf Me.TotalStuds >= 61 And Me.TotalStuds <= 120 Then
stAlb = "15"
ElseIf Me.TotalStuds >= 121 And Me.TotalStuds <= 180 Then
stAlb = "20"
ElseIf Me.TotalStuds >= 181 And Me.TotalStuds <= 240 Then
stAlb = "25"
ElseIf Me.TotalStuds >= 241 And Me.TotalStuds <= 300 Then
stAlb = "30"
ElseIf Me.TotalStuds >= 301 And Me.TotalStuds <= 360 Then
stAlb = "35"
ElseIf Me.TotalStuds >= 361 And Me.TotalStuds <= 420 Then
stAlb = "40"
ElseIf Me.TotalStuds >= 421 And Me.TotalStuds <= 480 Then
stAlb = "45"
ElseIf Me.TotalStuds >= 481 Then
stAlb = "50"
End If
ElseIf Me.paper_line Like "*I 33*" Then
stPN = "0"
stAlb = "0"
'if the paper is internal Wellington
If Me.TotalStuds <= 20 Then
stWel = "15"
ElseIf Me.TotalStuds >= 21 And Me.TotalStuds <= 60 Then
stWel = "20"
ElseIf Me.TotalStuds >= 61 And Me.TotalStuds <= 120 Then
stWel = "30"
ElseIf Me.TotalStuds >= 121 And Me.TotalStuds <= 180 Then
stWel = "35"
ElseIf Me.TotalStuds >= 181 And Me.TotalStuds <= 240 Then
stWel = "40"
ElseIf Me.TotalStuds >= 241 And Me.TotalStuds <= 300 Then
stWel = "45"
ElseIf Me.TotalStuds >= 301 And Me.TotalStuds <= 360 Then
stWel = "50"
ElseIf Me.TotalStuds >= 361 And Me.TotalStuds <= 420 Then
stWel = "55"
ElseIf Me.TotalStuds >= 421 And Me.TotalStuds <= 480 Then
stWel = "60"
ElseIf Me.TotalStuds >= 481 Then
stWel = "65"
End If
End If
'Looks if the paper is extramural or not. Assigns the number of extra
copies
If sExtra = True Then
Me.txtEM = sECopies
Else
Me.txtPN = stPN
Me.txtAlb = stAlb
Me.txtWel = stWel
Me.txtEMExtras = "0"
End If
End Sub
and I realise that I'm not even sure I'm barking up the right tree! I
hope some of you might be able to enlighten me
What I want to do, in a nutshell, is to calculate how many exam papers
to print, based on a number of factor (including how many students are
sitting the exam and the location of the exam).
I am working with an inherited poorly designed database to start, and
I have *no* control over that. I have what I have, and I have to work
with it, unfortunately.
In one table (Examsbm), I have a list of paper offerings, and fields
for how many copies to print.
In another table(Studpervenue), I have a list of all students sitting
exams, and their location.
There's basically 4 locations. PN, Wel, Alb, and Extramural.
Extramural is complicated by the fact that I have nearly 75 venues.
So, if the location is PN, Wel or Alb, there is nothing in the venue
field. If it's Extramural, there's a venue reference.
Using a query with Group By on the student's table, I was able to
calculate how many students are sitting at each location/venue.
I based a form on that query, and using the code at the bottom (sorry
for the long, somewhat messy code), I am able to determine how many
papers need to be printed for each paper offering, broken down by
venue.
Which is fine, however, the next step I need to do is to compile the
information from all the venues into one to determine the number of
papers to print for the Extramural location. Then I need to write
that information to the Examsbm table, as Studpervenue is a temporary
table.
I have a feeling I'm going about this the wrong way. If anyone could
help and point a kind finger in the right direction, I would greatly
appreciate it.
Thanks
===
Note that the code below is really only just to apply the right
calculations, which I don't feel would have worked in a query, what
with the resulting nested if/then, etc.
Private Sub Form_Current()
Dim sExtra As String
sExtra = (Me.paper_line Like "*E*" Or Me.paper_line Like "*B*")
'Calculates the number of extra copies for extramural papers
'Puts the value in sECopies
Dim sECopies As String
Dim stEAlb As String
If Me.exam_centre Like "1010*" Then
If Me.TotalStuds >= 1 And Me.TotalStuds <= 4 Then
sECopies = "5"
Me.txtEMExtras = "5"
ElseIf Me.TotalStuds >= 5 And Me.TotalStuds <= 9 Then
sECopies = "5"
Me.txtEMExtras = "10"
ElseIf Me.TotalStuds >= 10 And Me.TotalStuds <= 14 Then
sECopies = "10"
Me.txtEMExtras = "15"
ElseIf Me.TotalStuds >= 15 Then
sECopies = "10"
Me.txtEMExtras = "20"
End If
Else
If Me.TotalStuds >= 1 And Me.TotalStuds <= 4 Then
sECopies = "2"
Me.txtEMExtras = "5"
ElseIf Me.TotalStuds >= 5 And Me.TotalStuds <= 9 Then
sECopies = "3"
Me.txtEMExtras = "10"
ElseIf Me.TotalStuds >= 10 And Me.TotalStuds <= 14 Then
sECopies = "4"
Me.txtEMExtras = "15"
ElseIf Me.TotalStuds >= 15 Then
sECopies = "5"
Me.txtEMExtras = "20"
End If
End If
'Calculates the number of extra copies for internal papers
'Puts the value in sICopies
Dim sICopies As String
Dim stPN As String
Dim stAlb As String
Dim stWel As String
If Me.paper_line Like "*I 4*" Or Me.paper_line Like "*I2 4*" Or
Me.paper_line Like "*I 15*" Or Me.paper_line Like "*I 20*" Then
stWel = "0"
stAlb = "0"
If Me.TotalStuds <= 5 Then
stPN = "10"
ElseIf Me.TotalStuds >= 6 And Me.TotalStuds <= 30 Then
stPN = "15"
ElseIf Me.TotalStuds >= 31 And Me.TotalStuds <= 60 Then
stPN = "20"
ElseIf Me.TotalStuds >= 61 And Me.TotalStuds <= 120 Then
stPN = "25"
ElseIf Me.TotalStuds >= 121 And Me.TotalStuds <= 180 Then
stPN = "30"
ElseIf Me.TotalStuds >= 181 And Me.TotalStuds <= 240 Then
stPN = "35"
ElseIf Me.TotalStuds >= 241 And Me.TotalStuds <= 300 Then
stPN = "40"
ElseIf Me.TotalStuds >= 301 And Me.TotalStuds <= 360 Then
stPN = "45"
ElseIf Me.TotalStuds >= 361 And Me.TotalStuds <= 420 Then
stPN = "50"
ElseIf Me.TotalStuds >= 421 And Me.TotalStuds <= 480 Then
stPN = "55"
ElseIf Me.TotalStuds >= 481 Then
stPN = "60"
End If
ElseIf Me.paper_line Like "*I 10*" Then
stPN = "0"
stWel = "0"
'if the paper is internal Albany
If Me.TotalStuds <= 60 Then
stAlb = "10"
ElseIf Me.TotalStuds >= 61 And Me.TotalStuds <= 120 Then
stAlb = "15"
ElseIf Me.TotalStuds >= 121 And Me.TotalStuds <= 180 Then
stAlb = "20"
ElseIf Me.TotalStuds >= 181 And Me.TotalStuds <= 240 Then
stAlb = "25"
ElseIf Me.TotalStuds >= 241 And Me.TotalStuds <= 300 Then
stAlb = "30"
ElseIf Me.TotalStuds >= 301 And Me.TotalStuds <= 360 Then
stAlb = "35"
ElseIf Me.TotalStuds >= 361 And Me.TotalStuds <= 420 Then
stAlb = "40"
ElseIf Me.TotalStuds >= 421 And Me.TotalStuds <= 480 Then
stAlb = "45"
ElseIf Me.TotalStuds >= 481 Then
stAlb = "50"
End If
ElseIf Me.paper_line Like "*I 33*" Then
stPN = "0"
stAlb = "0"
'if the paper is internal Wellington
If Me.TotalStuds <= 20 Then
stWel = "15"
ElseIf Me.TotalStuds >= 21 And Me.TotalStuds <= 60 Then
stWel = "20"
ElseIf Me.TotalStuds >= 61 And Me.TotalStuds <= 120 Then
stWel = "30"
ElseIf Me.TotalStuds >= 121 And Me.TotalStuds <= 180 Then
stWel = "35"
ElseIf Me.TotalStuds >= 181 And Me.TotalStuds <= 240 Then
stWel = "40"
ElseIf Me.TotalStuds >= 241 And Me.TotalStuds <= 300 Then
stWel = "45"
ElseIf Me.TotalStuds >= 301 And Me.TotalStuds <= 360 Then
stWel = "50"
ElseIf Me.TotalStuds >= 361 And Me.TotalStuds <= 420 Then
stWel = "55"
ElseIf Me.TotalStuds >= 421 And Me.TotalStuds <= 480 Then
stWel = "60"
ElseIf Me.TotalStuds >= 481 Then
stWel = "65"
End If
End If
'Looks if the paper is extramural or not. Assigns the number of extra
copies
If sExtra = True Then
Me.txtEM = sECopies
Else
Me.txtPN = stPN
Me.txtAlb = stAlb
Me.txtWel = stWel
Me.txtEMExtras = "0"
End If
End Sub