Type Mismatch

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

    Type Mismatch

    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

    Code:
    Dim newSectionRecord 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_Click()
    
    Call DDFrame(fraAdvisers)
    
    lstAdvisers.ListItems.Clear
    
        Dim rsAdvisers As New ADODB.Recordset
        
        Call PopulateList(lstAdvisers, "SELECT `t_faculty`.`FacultyID`,`t_faculty`.`FacultyFName`,`t_faculty`.`FacultyMI`,`t_faculty`.`FacultyLName`,`t_faculty`.`DepartmentID`FROM `t_faculty`", rsAdvisers)
        
        
    End Sub
    
    Private Sub cmdMajor_Click()
    Call DDFrame(fraSearch)
    
    lstCourse.ListItems.Clear
    
        Dim rsCourse As New ADODB.Recordset
        
       'Call PopulateList(lstCourse, "SELECT`t_course`.`CourseID`,`t_course`.`CourseName`,`t_major`.`Major`FROM `t_course`INNER JOIN `t_major` ON (`t_major`.`MajorID` = `t_course`.`MajorID`)", rsCourse)
        Call PopulateList(lstCourse, "SELECT `t_course`.`CourseID`,`t_course`.`CourseName`,`t_major`.`Major`,`t_department`.`Department`FROM `t_course`INNER JOIN `t_department` ON (`t_department`.`DepartmentID` = `t_course`.`DepartmentID`)INNER JOIN `t_major` ON (`t_major`.`MajorID` = `t_course`.`MajorID`)", rsCourse)
    End Sub
    
    Private Sub cmdSave_Click()
    
    txtCaption.Text = txtSectionName.Text & "" & txtYearLevel.Text & "" & txtSec.Text
      
      Call GetDataForSectionRecord
     
          '  If EditFlag = False Then
                Call modSection.AddNew(newSectionRecord)
          '  Else
          '      Call modSection.Update(newSectionRecord)
          '  End If
    
    'Call InitForm
        
    
    
       SectionID = 0
       
    
    End Sub
    
    Private Sub cmdYearLevel_Click()
    Call DDFrame(fraYearLevel)
    
    'fraSearch.Width = 3255
    'fraSearch.Height = 3495
    'fraSearch.Top = 2280
    'fraSearch.Left = 240
    
    lstYearLevel.ListItems.Clear
    
        Dim rsYearLevel As New ADODB.Recordset
        Call PopulateList(lstYearLevel, "SELECT `t_year`.`YearID`,`t_year`.`Year`FROM `t_year`", rsYearLevel)
        
    End Sub
    
    Private Sub Form_Load()
    
    Me.Caption = "Section"
    Call ClearForm(Me)
    
    End Sub
    
    
    
    Private Sub lstAdvisers_Click()
    
    txtAdviser.Text = lstAdvisers.SelectedItem.SubItems(1) & " " & lstAdvisers.SelectedItem.SubItems(2) & " " & lstAdvisers.SelectedItem.SubItems(3)
    FacultyID = lstAdvisers.SelectedItem.Text
    fraAdvisers.Visible = False
    
    End Sub
    
    Private Sub lstCourse_Click()
    txtCourse.Text = lstCourse.SelectedItem.SubItems(1) & " - " & lstCourse.SelectedItem.SubItems(2)
    txtSectionName = lstCourse.SelectedItem.SubItems(1) & " - " & lstCourse.SelectedItem.SubItems(2)
    txtDepartment.Text = lstCourse.SelectedItem.SubItems(2)
    CourseID = lstCourse.SelectedItem.Text
    
    fraSearch.Visible = False
    End Sub
    
    
    
    Private Sub lstYearLevel_Click()
    txtYearLevel = lstYearLevel.SelectedItem.SubItems(1)
    YearLevelID = lstYearLevel.SelectedItem.Text
    
    fraYearLevel.Visible = False
    
    
    End Sub
    
    Private Sub GetDataForSectionRecord()
    
    '''''''''''''''''''''''''''''''''''' the Section will be highlighted every time I got an error''''''''''''''''''
    
        With newSectionRecord
            
       
             .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(newSectionRecord As SectionRecord)
    
        With mySectionRecord
        '    If CESDBConn.Execute("SELECT `t_section`.`Section`,`t_section`.`SectionSize`,`t_section`.`FacultyID`,`t_section`.`CourseID`FROM `t_section`WHERE  (`Section` LIKE ' Section') AND (`SectionSize` LIKE 'SectionSize') AND (`FacultyID` LIKE 'FacultyID') AND (`CourseID` LIKE 'CourseID')").EOF Then
                    
                    CESDBConn.Execute "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 + vbApplicationModal + vbDefaultButton1, "Section")
          '      Exit Sub
         '   End If
        End With
    
        
    
    
    End Sub
    please help me......please. ..>God bless
    Last edited by Dököll; Jan 1 '09, 02:36 AM. Reason: code tags...
  • Dököll
    Recognized Expert Top Contributor
    • Nov 2006
    • 2379

    #2
    Greetings, nurikoAnna!

    Are you using Microsoft Access? You could need to add a reference to it, and addtionally, a reference ADO or DAO could be needed. I have seen this before with DAO, and that has fixed it when a reference was added:-)

    Hope this helps!

    Dököll

    Comment

    • nurikoAnna
      New Member
      • Nov 2008
      • 26

      #3
      i am using mysql ....

      Comment

      • lotus18
        Contributor
        • Nov 2007
        • 865

        #4
        Type Mismatch

        It seems like you are trying to insert an invalid value to your column. For example, inserting char or varchar value to a double or integer type. Check your columns' datatype.


        Rey Sean

        Comment

        Working...