Connecting Tech Pros Worldwide Help | Site Map

Type Mismatch

nurikoAnna's Avatar
Newbie
 
Join Date: Nov 2008
Posts: 26
#1: Nov 11 '08
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

Expand|Select|Wrap|Line Numbers
  1. Dim newSectionRecord As SectionRecord
  2. Dim EditFlag As Boolean
  3. Dim CourseID As Long
  4. Dim YearLevelID As Long
  5. Dim FacultyID As Long
  6. Dim SectionID As Long
  7.  
  8. Private Sub cmdAdviser_Click()
  9.  
  10. Call DDFrame(fraAdvisers)
  11.  
  12. lstAdvisers.ListItems.Clear
  13.  
  14.     Dim rsAdvisers As New ADODB.Recordset
  15.  
  16.     Call PopulateList(lstAdvisers, "SELECT `t_faculty`.`FacultyID`,`t_faculty`.`FacultyFName`,`t_faculty`.`FacultyMI`,`t_faculty`.`FacultyLName`,`t_faculty`.`DepartmentID`FROM `t_faculty`", rsAdvisers)
  17.  
  18.  
  19. End Sub
  20.  
  21. Private Sub cmdMajor_Click()
  22. Call DDFrame(fraSearch)
  23.  
  24. lstCourse.ListItems.Clear
  25.  
  26.     Dim rsCourse As New ADODB.Recordset
  27.  
  28.    '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)
  29.     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)
  30. End Sub
  31.  
  32. Private Sub cmdSave_Click()
  33.  
  34. txtCaption.Text = txtSectionName.Text & "" & txtYearLevel.Text & "" & txtSec.Text
  35.  
  36.   Call GetDataForSectionRecord
  37.  
  38.       '  If EditFlag = False Then
  39.             Call modSection.AddNew(newSectionRecord)
  40.       '  Else
  41.       '      Call modSection.Update(newSectionRecord)
  42.       '  End If
  43.  
  44. 'Call InitForm
  45.  
  46.  
  47.  
  48.    SectionID = 0
  49.  
  50.  
  51. End Sub
  52.  
  53. Private Sub cmdYearLevel_Click()
  54. Call DDFrame(fraYearLevel)
  55.  
  56. 'fraSearch.Width = 3255
  57. 'fraSearch.Height = 3495
  58. 'fraSearch.Top = 2280
  59. 'fraSearch.Left = 240
  60.  
  61. lstYearLevel.ListItems.Clear
  62.  
  63.     Dim rsYearLevel As New ADODB.Recordset
  64.     Call PopulateList(lstYearLevel, "SELECT `t_year`.`YearID`,`t_year`.`Year`FROM `t_year`", rsYearLevel)
  65.  
  66. End Sub
  67.  
  68. Private Sub Form_Load()
  69.  
  70. Me.Caption = "Section"
  71. Call ClearForm(Me)
  72.  
  73. End Sub
  74.  
  75.  
  76.  
  77. Private Sub lstAdvisers_Click()
  78.  
  79. txtAdviser.Text = lstAdvisers.SelectedItem.SubItems(1) & " " & lstAdvisers.SelectedItem.SubItems(2) & " " & lstAdvisers.SelectedItem.SubItems(3)
  80. FacultyID = lstAdvisers.SelectedItem.Text
  81. fraAdvisers.Visible = False
  82.  
  83. End Sub
  84.  
  85. Private Sub lstCourse_Click()
  86. txtCourse.Text = lstCourse.SelectedItem.SubItems(1) & " - " & lstCourse.SelectedItem.SubItems(2)
  87. txtSectionName = lstCourse.SelectedItem.SubItems(1) & " - " & lstCourse.SelectedItem.SubItems(2)
  88. txtDepartment.Text = lstCourse.SelectedItem.SubItems(2)
  89. CourseID = lstCourse.SelectedItem.Text
  90.  
  91. fraSearch.Visible = False
  92. End Sub
  93.  
  94.  
  95.  
  96. Private Sub lstYearLevel_Click()
  97. txtYearLevel = lstYearLevel.SelectedItem.SubItems(1)
  98. YearLevelID = lstYearLevel.SelectedItem.Text
  99.  
  100. fraYearLevel.Visible = False
  101.  
  102.  
  103. End Sub
  104.  
  105. Private Sub GetDataForSectionRecord()
  106.  
  107. '''''''''''''''''''''''''''''''''''' the Section will be highlighted every time I got an error''''''''''''''''''
  108.  
  109.     With newSectionRecord
  110.  
  111.  
  112.          .Section = txtCaption.Text
  113.          .SectionSize = txtSectionSize.Text
  114.          .FacultyID = FacultyID
  115.          .CourseID = txtCourse.Text
  116.  
  117.     End With
  118.  
  119. End Sub
  120.  
  121.  
  122. '''' '''''This codes are coded in the module name modSection''''''''''''''''''
  123.  
  124.  
  125.  
  126. Public Type SectionRecord
  127.  
  128.     SectionID As Long
  129.     Section As Long
  130.     SectionSize As Long
  131.     FacultyID As Long
  132.     CourseID As Long
  133.  
  134.  
  135. End Type
  136.  
  137.  
  138. Sub AddNew(newSectionRecord As SectionRecord)
  139.  
  140.     With mySectionRecord
  141.     '    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
  142.  
  143.                 CESDBConn.Execute "INSERT INTO `t_section` (`Section`, `SectionSize`, `FacultyID`, `CourseID`)" & _
  144.                 " VALUES ('" & .Section & "', '" & .SectionSize & "' , '" & .FacultyID & "' ,'" & .CourseID & "')"
  145.          '   Exit Sub
  146.      '   Else
  147.             Call MsgBox("Record already exist in database.", vbOKOnly + vbExclamation + vbApplicationModal + vbDefaultButton1, "Section")
  148.       '      Exit Sub
  149.      '   End If
  150.     End With
  151.  
  152.  
  153.  
  154.  
  155. End Sub
  156.  
  157.  
please help me......please...>God bless
Dököll's Avatar
Moderator
 
Join Date: Nov 2006
Location: Upstate NY - US
Posts: 2,267
#2: Jan 1 '09

re: Type Mismatch


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
nurikoAnna's Avatar
Newbie
 
Join Date: Nov 2008
Posts: 26
#3: Jan 6 '09

re: Type Mismatch


i am using mysql ....
lotus18's Avatar
Site Addict
 
Join Date: Nov 2007
Location: Zamboanga City, Philippines
Posts: 857
#4: Jan 6 '09

re: Type Mismatch


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
Reply