Type Mismatch

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nurikoAnna
    New Member
    • Nov 2008
    • 26

    Type Mismatch

    Question posted by: nurikoAnna (Newbie) on Today 12:30 AM
    Hi Gooday!!!

    When I click my save button for saving I always got this error "Type Mismatch "

    I don't know why....


    Here is my codes


    Dim newSectionRecor d As SectionRecord
    Dim EditFlag As Boolean
    Dim CourseID As Long
    Dim YearLevelID As Long
    Dim FacultyID As Long
    Dim SectionID As Long

    Private Sub cmdAdviser_Clic k()

    Call DDFrame(fraAdvi sers)

    lstAdvisers.Lis tItems.Clear

    Dim rsAdvisers As New ADODB.Recordset

    Call PopulateList(ls tAdvisers, "SELECT `t_faculty`.`Fa cultyID`,`t_fac ulty`.`FacultyF Name` ,`t_faculty`.`F acultyMI`,`t_fa culty`.`Faculty LName `,`t_faculty`.` DepartmentID`FR OM `t_faculty`", rsAdvisers)


    End Sub

    Private Sub cmdMajor_Click( )
    Call DDFrame(fraSear ch)

    lstCourse.ListI tems.Clear

    Dim rsCourse As New ADODB.Recordset

    'Call PopulateList(ls tCourse, "SELECT`t_cours e`.`CourseID`,` t_course`.`Cour seName `,`t_major`.`Ma jor`FROM `t_course`INNER JOIN `t_major` ON (`t_major`.`Maj orID` = `t_course`.`Maj orID`)", rsCourse)
    Call PopulateList(ls tCourse, "SELECT `t_course`.`Cou rseID`,`t_cours e`.`CourseName` ,`t_m ajor`.`Major`,` t_department`.` Department`FROM `t_course`INNER JOIN `t_department` ON (`t_department` .`DepartmentID` = `t_course`.`Dep artmentID`)INNE R JOIN `t_major` ON (`t_major`.`Maj orID` = `t_course`.`Maj orID`)", rsCourse)
    End Sub

    Private Sub cmdSave_Click()

    txtCaption.Text = txtSectionName. Text & "" & txtYearLevel.Te xt & "" & txtSec.Text

    Call GetDataForSecti onRecord

    ' If EditFlag = False Then
    Call modSection.AddN ew(newSectionRe cord)
    ' Else
    ' Call modSection.Upda te(newSectionRe cord)
    ' End If

    'Call InitForm



    SectionID = 0


    End Sub

    Private Sub cmdYearLevel_Cl ick()
    Call DDFrame(fraYear Level)

    'fraSearch.Widt h = 3255
    'fraSearch.Heig ht = 3495
    'fraSearch.Top = 2280
    'fraSearch.Left = 240

    lstYearLevel.Li stItems.Clear

    Dim rsYearLevel As New ADODB.Recordset
    Call PopulateList(ls tYearLevel, "SELECT `t_year`.`YearI D`,`t_year`.`Ye ar`FROM `t_year`", rsYearLevel)

    End Sub

    Private Sub Form_Load()

    Me.Caption = "Section"
    Call ClearForm(Me)

    End Sub



    Private Sub lstAdvisers_Cli ck()

    txtAdviser.Text = lstAdvisers.Sel ectedItem.SubIt ems(1) & " " & lstAdvisers.Sel ectedItem.SubIt ems(2) & " " & lstAdvisers.Sel ectedItem.SubIt ems(3)
    FacultyID = lstAdvisers.Sel ectedItem.Text
    fraAdvisers.Vis ible = False

    End Sub

    Private Sub lstCourse_Click ()
    txtCourse.Text = lstCourse.Selec tedItem.SubItem s(1) & " - " & lstCourse.Selec tedItem.SubItem s(2)
    txtSectionName = lstCourse.Selec tedItem.SubItem s(1) & " - " & lstCourse.Selec tedItem.SubItem s(2)
    txtDepartment.T ext = lstCourse.Selec tedItem.SubItem s(2)
    CourseID = lstCourse.Selec tedItem.Text

    fraSearch.Visib le = False
    End Sub



    Private Sub lstYearLevel_Cl ick()
    txtYearLevel = lstYearLevel.Se lectedItem.SubI tems(1)
    YearLevelID = lstYearLevel.Se lectedItem.Text

    fraYearLevel.Vi sible = False


    End Sub

    Private Sub GetDataForSecti onRecord()

    ''''''''''''''' ''''''''''''''' '''''' the Section will be highlighted every time I got an error'''''''''' ''''''''

    With newSectionRecor d


    .Section = txtCaption.Text
    .SectionSize = txtSectionSize. Text
    .FacultyID = FacultyID
    .CourseID = txtCourse.Text

    End With

    End Sub


    '''' '''''This codes are coded in the module name modSection''''' '''''''''''''



    Public Type SectionRecord

    SectionID As Long
    Section As Long
    SectionSize As Long
    FacultyID As Long
    CourseID As Long


    End Type


    Sub AddNew(newSecti onRecord As SectionRecord)

    With mySectionRecord
    ' If CESDBConn.Execu te("SELECT `t_section`.`Se ction`,`t_secti on`.`SectionSiz e`,`t _section`.`Facu ltyID`,`t_secti on`.`CourseID`F ROM `t_section`WHER E (`Section` LIKE ' Section') AND (`SectionSize` LIKE 'SectionSize') AND (`FacultyID` LIKE 'FacultyID') AND (`CourseID` LIKE 'CourseID')").E OF Then

    CESDBConn.Execu te "INSERT INTO `t_section` (`Section`, `SectionSize`, `FacultyID`, `CourseID`)" & _
    " VALUES ('" & .Section & "', '" & .SectionSize & "' , '" & .FacultyID & "' ,'" & .CourseID & "')"
    ' Exit Sub
    ' Else
    Call MsgBox("Record already exist in database.", vbOKOnly + vbExclamation + vbApplicationMo dal + vbDefaultButton 1, "Section")
    ' Exit Sub
    ' End If
    End With




    End Sub



    please help me......please. ..>God bless
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    question moved to vb forum.

    Comment

    • jg007
      Contributor
      • Mar 2008
      • 283

      #3
      I haven't really done much with SQL but looking at the code I am not sure if you are using the correct types as they are all down as long in the class and then you are using text values

      Code:
      .Section = txtCaption.Text
      .SectionSize = txtSectionSize.Text
      .FacultyID = FacultyID
      .CourseID = txtCourse.Text
      &

      Code:
      SectionID As Long
      Section As Long
      SectionSize As Long
      FacultyID As Long
      CourseID As Long

      Comment

      • nurikoAnna
        New Member
        • Nov 2008
        • 26

        #4
        Thank you so much...I get it...thanks a lot...I was unconscious about that...thanks.. .God bless..

        Comment

        Working...