DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Re: Please help - Arthur Wood

  1. #1
    Abdul Guest

    Re: Please help - Arthur Wood


    Hi Arthur,

    here is the code for one of the comands I am hving a problem. I am trying
    to calculate the cummulative grade for a student

    Thanks
    Abdul


    Private Sub cmdCumulative_Click()

    Dim CumulativeGrade As Single
    Dim Credit As Single
    Dim FinalGrade As Single
    Dim NumGrade As Single
    Dim ClassCredit As Integer

    StdId = Val(cboStudentID.Text)
    'the student ID must be selected from the cmbo box
    'if not selected indicate student ID to be selected

    If StdId = 0 Then
    MsgBox "Student ID has not been Seklected" & _
    "Please select Student ID from the Drop Down List", vbCritical
    + vbOKCancel, "WARNING"
    cboStudentID.SetFocus
    End If

    'If the user has swelected student ID

    If StdId <> 0 Then

    Adodc1.RecordSource = "SELECT Enrollment.Student_ID, Enrollment.ClassYear,
    Enrollment.Grade, " & _
    "Enrollment.Semester, Class.Class_Number, Class.Class_Credits "
    & _
    "FROM Class RIGHT JOIN Enrollment ON Class.Class_Number = Enrollment.Class_Number
    where " & _
    "((Enrollment.Student_ID) = " & StdId & ") order by ClassYear asc"

    ' Adodc1.Refresh

    'Calculate the cumulative average of the selected student from the stident
    ID combo box
    'The CumulativeGrade tallies up the cumulative grade of the selected student
    'The ClassCredit tallies up the cumulative credits

    CumulativeGrade = 0
    ClassCredit = 0

    With Adodc1.Recordset
    '.MoveFirst
    Do While Not .EOF

    'reformat letter grades to scores to calculate grade

    Select Case UCase(.Fields("grade").Value)
    Case Is = "A"
    NumGrade = 4
    Case Is = "B"
    NumGrade = 3
    Case Is = "C"
    NumGrade = 2
    Case Is = "D"
    NumGrade = 1
    Case Is = "F"
    NumGrade = 0
    End Select

    'do not count credits of class not completed

    If .Fields("grade").Value = "" Then
    Credit = 0
    Else
    Credit = .Fields("Class_Credits").Value
    '**********************************************************************
    '**the erros comes when trying to read class_credits from class table
    fered in the form as datasource Adodc2
    ***********************************************************************
    End If

    CumulativeGrade = CumulativeGrade + (NumGrade * Credit)

    ClassCredit = ClassCredit + Credit
    .MoveNext

    Loop

    End With

    'Now calculate the final cumulative grade

    FinalGrade = CumulativeGrade / ClassCredit

    'Now return the calculated final grade into the cumulative grade text box
    txtCumulativeGrade.Text = FinalGrade


    End If







    "Arthur Wood" <wooda@nospam.com> wrote:
    >
    >Abdul,
    > What "Commands" are you having trouble with. Post them here, and MORE
    >thast one person can offer assistance. If you can only email the project,
    >then you are NOT very likely to receive any assiatance, quickly enough.
    >
    >Arthur Wood
    >
    >




  2. #2
    Arthur Wood Guest

    Re: Please help - Arthur Wood


    Abdul,
    I do not understand what you are trying to do. What is ADODC2? and how
    is it related to ADODC1? You say you get an error "the erros comes when
    trying to read class_credits from class table
    fered in the form as datasource Adodc2" I do not understand what you are
    trying to do here. What error message do you get?

    Arthur Wood



    "Abdul" <Abdul@MWCOG.Org> wrote:
    >
    >Hi Arthur,
    >
    >here is the code for one of the comands I am hving a problem. I am trying
    >to calculate the cummulative grade for a student
    >
    >Thanks
    >Abdul
    >
    >
    >Private Sub cmdCumulative_Click()
    >
    > Dim CumulativeGrade As Single
    > Dim Credit As Single
    > Dim FinalGrade As Single
    > Dim NumGrade As Single
    > Dim ClassCredit As Integer
    >
    > StdId = Val(cboStudentID.Text)
    > 'the student ID must be selected from the cmbo box
    > 'if not selected indicate student ID to be selected
    >
    > If StdId = 0 Then
    > MsgBox "Student ID has not been Seklected" & _
    > "Please select Student ID from the Drop Down List", vbCritical
    >+ vbOKCancel, "WARNING"
    > cboStudentID.SetFocus
    > End If
    >
    > 'If the user has swelected student ID
    >
    > If StdId <> 0 Then
    >
    > Adodc1.RecordSource = "SELECT Enrollment.Student_ID, Enrollment.ClassYear,
    >Enrollment.Grade, " & _
    > "Enrollment.Semester, Class.Class_Number, Class.Class_Credits "
    >& _
    > "FROM Class RIGHT JOIN Enrollment ON Class.Class_Number = Enrollment.Class_Number
    >where " & _
    > "((Enrollment.Student_ID) = " & StdId & ") order by ClassYear asc"
    >
    > ' Adodc1.Refresh
    >
    > 'Calculate the cumulative average of the selected student from the stident
    >ID combo box
    > 'The CumulativeGrade tallies up the cumulative grade of the selected student
    > 'The ClassCredit tallies up the cumulative credits
    >
    > CumulativeGrade = 0
    > ClassCredit = 0
    >
    > With Adodc1.Recordset
    > '.MoveFirst
    > Do While Not .EOF
    >
    > 'reformat letter grades to scores to calculate grade
    >
    > Select Case UCase(.Fields("grade").Value)
    > Case Is = "A"
    > NumGrade = 4
    > Case Is = "B"
    > NumGrade = 3
    > Case Is = "C"
    > NumGrade = 2
    > Case Is = "D"
    > NumGrade = 1
    > Case Is = "F"
    > NumGrade = 0
    > End Select
    >
    > 'do not count credits of class not completed
    >
    > If .Fields("grade").Value = "" Then
    > Credit = 0
    > Else
    > Credit = .Fields("Class_Credits").Value
    >'**********************************************************************
    > '**the erros comes when trying to read class_credits from class table


    > fered in the form as datasource Adodc2
    >***********************************************************************
    > End If
    >
    > CumulativeGrade = CumulativeGrade + (NumGrade * Credit)
    >
    > ClassCredit = ClassCredit + Credit
    > .MoveNext
    >
    > Loop
    >
    >End With
    >
    > 'Now calculate the final cumulative grade
    >
    > FinalGrade = CumulativeGrade / ClassCredit
    >
    > 'Now return the calculated final grade into the cumulative grade text

    box
    > txtCumulativeGrade.Text = FinalGrade
    >
    >
    >End If
    >
    >
    >
    >
    >
    >
    >
    >"Arthur Wood" <wooda@nospam.com> wrote:
    >>
    >>Abdul,
    >> What "Commands" are you having trouble with. Post them here, and MORE
    >>thast one person can offer assistance. If you can only email the project,
    >>then you are NOT very likely to receive any assiatance, quickly enough.
    >>
    >>Arthur Wood
    >>
    >>

    >
    >



  3. #3
    dnagel Guest

    Re: Please help - Arthur Wood

    I saw the same thing...

    In this line of code



    frmGrade: Private Sub cmdCumulative_Click()



    'do not count credits of class not completed



    If .Fields("grade").Value = "" Then

    Credit = 0

    Else

    Credit = .Fields("Class_Credits").Value

    End If





    Class_Credits



    Does not exist in the recordset that’s open…



    These are the fields available to you…



    Grade

    Semester

    ClassYear

    Class_Number

    Student_ID



    I think he's trying to calculate an average, but the math is
    a bit off kilter...

    Did you design the algorithym before attempting to code it?

    D?

    "Arthur Wood" <wooda@nospam.com> wrote in message news:3c995d7d$1@10.1.10.29...
    >
    > Abdul,
    > I do not understand what you are trying to do. What is ADODC2? and how
    > is it related to ADODC1? You say you get an error "the erros comes when
    > trying to read class_credits from class table
    > fered in the form as datasource Adodc2" I do not understand what you are
    > trying to do here. What error message do you get?
    >
    > Arthur Wood
    >
    >
    >
    > "Abdul" <Abdul@MWCOG.Org> wrote:
    > >
    > >Hi Arthur,
    > >
    > >here is the code for one of the comands I am hving a problem. I am trying
    > >to calculate the cummulative grade for a student
    > >
    > >Thanks
    > >Abdul
    > >
    > >
    > >Private Sub cmdCumulative_Click()
    > >
    > > Dim CumulativeGrade As Single
    > > Dim Credit As Single
    > > Dim FinalGrade As Single
    > > Dim NumGrade As Single
    > > Dim ClassCredit As Integer
    > >
    > > StdId = Val(cboStudentID.Text)
    > > 'the student ID must be selected from the cmbo box
    > > 'if not selected indicate student ID to be selected
    > >
    > > If StdId = 0 Then
    > > MsgBox "Student ID has not been Seklected" & _
    > > "Please select Student ID from the Drop Down List", vbCritical
    > >+ vbOKCancel, "WARNING"
    > > cboStudentID.SetFocus
    > > End If
    > >
    > > 'If the user has swelected student ID
    > >
    > > If StdId <> 0 Then
    > >
    > > Adodc1.RecordSource = "SELECT Enrollment.Student_ID, Enrollment.ClassYear,
    > >Enrollment.Grade, " & _
    > > "Enrollment.Semester, Class.Class_Number, Class.Class_Credits "
    > >& _
    > > "FROM Class RIGHT JOIN Enrollment ON Class.Class_Number = Enrollment.Class_Number
    > >where " & _
    > > "((Enrollment.Student_ID) = " & StdId & ") order by ClassYear asc"
    > >
    > > ' Adodc1.Refresh
    > >
    > > 'Calculate the cumulative average of the selected student from the stident
    > >ID combo box
    > > 'The CumulativeGrade tallies up the cumulative grade of the selected student
    > > 'The ClassCredit tallies up the cumulative credits
    > >
    > > CumulativeGrade = 0
    > > ClassCredit = 0
    > >
    > > With Adodc1.Recordset
    > > '.MoveFirst
    > > Do While Not .EOF
    > >
    > > 'reformat letter grades to scores to calculate grade
    > >
    > > Select Case UCase(.Fields("grade").Value)
    > > Case Is = "A"
    > > NumGrade = 4
    > > Case Is = "B"
    > > NumGrade = 3
    > > Case Is = "C"
    > > NumGrade = 2
    > > Case Is = "D"
    > > NumGrade = 1
    > > Case Is = "F"
    > > NumGrade = 0
    > > End Select
    > >
    > > 'do not count credits of class not completed
    > >
    > > If .Fields("grade").Value = "" Then
    > > Credit = 0
    > > Else
    > > Credit = .Fields("Class_Credits").Value
    > >'**********************************************************************
    > > '**the erros comes when trying to read class_credits from class table

    >
    > > fered in the form as datasource Adodc2
    > >***********************************************************************
    > > End If
    > >
    > > CumulativeGrade = CumulativeGrade + (NumGrade * Credit)
    > >
    > > ClassCredit = ClassCredit + Credit
    > > .MoveNext
    > >
    > > Loop
    > >
    > >End With
    > >
    > > 'Now calculate the final cumulative grade
    > >
    > > FinalGrade = CumulativeGrade / ClassCredit
    > >
    > > 'Now return the calculated final grade into the cumulative grade text

    > box
    > > txtCumulativeGrade.Text = FinalGrade
    > >
    > >
    > >End If
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > >"Arthur Wood" <wooda@nospam.com> wrote:
    > >>
    > >>Abdul,
    > >> What "Commands" are you having trouble with. Post them here, and MORE
    > >>thast one person can offer assistance. If you can only email the project,
    > >>then you are NOT very likely to receive any assiatance, quickly enough.
    > >>
    > >>Arthur Wood
    > >>
    > >>

    > >
    > >

    >



  4. #4
    Abdul Guest

    Re: Please help - Arthur Wood


    Hi Arthur

    In my program I am refering a database and the ADODC is the data control,
    and Adodc1 refers to the first table, Adodc2 to the second table and so on.
    I was trying to calculate the cumulative grade of a student by getting grade
    from a class table to which class he had attended from the Enrollment table
    connecting the two tables by a variable Student_ID.
    The rpogram works fine if I am using just a data control (DAO).

    Thanks Abdul


    "Arthur Wood" <wooda@nospam.com> wrote:
    >
    >Abdul,
    > I do not understand what you are trying to do. What is ADODC2? and

    how
    >is it related to ADODC1? You say you get an error "the erros comes when
    >trying to read class_credits from class table
    > fered in the form as datasource Adodc2" I do not understand what you are
    >trying to do here. What error message do you get?
    >
    >Arthur Wood
    >
    >
    >
    >"Abdul" <Abdul@MWCOG.Org> wrote:
    >>
    >>Hi Arthur,
    >>
    >>here is the code for one of the comands I am hving a problem. I am trying
    >>to calculate the cummulative grade for a student
    >>
    >>Thanks
    >>Abdul
    >>
    >>
    >>Private Sub cmdCumulative_Click()
    >>
    >> Dim CumulativeGrade As Single
    >> Dim Credit As Single
    >> Dim FinalGrade As Single
    >> Dim NumGrade As Single
    >> Dim ClassCredit As Integer
    >>
    >> StdId = Val(cboStudentID.Text)
    >> 'the student ID must be selected from the cmbo box
    >> 'if not selected indicate student ID to be selected
    >>
    >> If StdId = 0 Then
    >> MsgBox "Student ID has not been Seklected" & _
    >> "Please select Student ID from the Drop Down List", vbCritical
    >>+ vbOKCancel, "WARNING"
    >> cboStudentID.SetFocus
    >> End If
    >>
    >> 'If the user has swelected student ID
    >>
    >> If StdId <> 0 Then
    >>
    >> Adodc1.RecordSource = "SELECT Enrollment.Student_ID, Enrollment.ClassYear,
    >>Enrollment.Grade, " & _
    >> "Enrollment.Semester, Class.Class_Number, Class.Class_Credits

    "
    >>& _
    >> "FROM Class RIGHT JOIN Enrollment ON Class.Class_Number = Enrollment.Class_Number
    >>where " & _
    >> "((Enrollment.Student_ID) = " & StdId & ") order by ClassYear

    asc"
    >>
    >> ' Adodc1.Refresh
    >>
    >> 'Calculate the cumulative average of the selected student from the stident
    >>ID combo box
    >> 'The CumulativeGrade tallies up the cumulative grade of the selected

    student
    >> 'The ClassCredit tallies up the cumulative credits
    >>
    >> CumulativeGrade = 0
    >> ClassCredit = 0
    >>
    >> With Adodc1.Recordset
    >> '.MoveFirst
    >> Do While Not .EOF
    >>
    >> 'reformat letter grades to scores to calculate grade
    >>
    >> Select Case UCase(.Fields("grade").Value)
    >> Case Is = "A"
    >> NumGrade = 4
    >> Case Is = "B"
    >> NumGrade = 3
    >> Case Is = "C"
    >> NumGrade = 2
    >> Case Is = "D"
    >> NumGrade = 1
    >> Case Is = "F"
    >> NumGrade = 0
    >> End Select
    >>
    >> 'do not count credits of class not completed
    >>
    >> If .Fields("grade").Value = "" Then
    >> Credit = 0
    >> Else
    >> Credit = .Fields("Class_Credits").Value
    >>'**********************************************************************
    >> '**the erros comes when trying to read class_credits from class table


    >
    >> fered in the form as datasource Adodc2
    >>***********************************************************************
    >> End If
    >>
    >> CumulativeGrade = CumulativeGrade + (NumGrade * Credit)
    >>
    >> ClassCredit = ClassCredit + Credit
    >> .MoveNext
    >>
    >> Loop
    >>
    >>End With
    >>
    >> 'Now calculate the final cumulative grade
    >>
    >> FinalGrade = CumulativeGrade / ClassCredit
    >>
    >> 'Now return the calculated final grade into the cumulative grade text

    >box
    >> txtCumulativeGrade.Text = FinalGrade
    >>
    >>
    >>End If
    >>
    >>
    >>
    >>
    >>
    >>
    >>
    >>"Arthur Wood" <wooda@nospam.com> wrote:
    >>>
    >>>Abdul,
    >>> What "Commands" are you having trouble with. Post them here, and MORE
    >>>thast one person can offer assistance. If you can only email the project,
    >>>then you are NOT very likely to receive any assiatance, quickly enough.
    >>>
    >>>Arthur Wood
    >>>
    >>>

    >>
    >>

    >



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center