Type Mismatch

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

    Type Mismatch

    I am having troubled debugging with my codes...It always gets an error "TYPE MISMATCH"


    Below is my code in my frmApplicantsEn try:


    _______________ _______________ _______________ _____ _______________ Private Mint As Integer
    Dim date1 As Date
    Dim date2 As Date
    Dim myApplicationRe cord As Application
    Dim myPersonalInfoR ecord As PersonalInfo
    Dim EditFlag As Boolean
    Dim CourseID As Long
    Dim ApplicationID As Long
    Dim PersonalInfoID As Long
    Dim ActiveSchoolYea rFrom As String, ActiveSchoolYea rTo As String
    Dim ActiveSchoolYea rID As Long
    'Dim CourseID As Long


    Private Sub cmdAdd_Click()

    'Call Enabledtxt(Me)
    Call UnLockedtxt(Me)
    Call EnabledCombo(Me )
    Call EnabledListBox( Me)
    Call cleartxtbox(Me)

    txtCourseApplie d.SetFocus
    DTPDateReg.Enab led = True


    txtAge.Locked = True
    cmdAdd.Enabled = False
    cmdEdit.Enabled = True
    cmdSave.Enabled = True
    cmdCancel.Enabl ed = True
    cmdCourseDown.E nabled = True



    End Sub

    Private Sub cmdCancel_Click ()

    Call cleartxtbox(Me)




    End Sub

    Private Sub cmdCourseDown_C lick()
    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)

    End Sub

    Private Sub cmdEdit_Click()

    Call UnLockedtxt(Me)

    End Sub

    Private Sub cmdSave_Click()


    'If DTPDateReg.Valu e < 1907 Then
    '
    ' Call MsgBox(" Please input a year not less than 1907", vbOKOnly + vbExclamation + vbApplicationMo dal + vbDefaultButton 1, "ERROR ON ENTRY!")
    ' ' txtFrom.SetFocu s
    ' ' cmdSave.Enabled = False
    ' ' cmdCancel.Enabl ed = False
    '
    ' Exit Sub
    '
    '
    'ElseIf DTPDateReg.Valu e > Format(Now, "mm/dd/yyyy") Then
    '
    ' Call MsgBox(" Please input a year not greater than the current", vbOKOnly + vbExclamation + vbApplicationMo dal + vbDefaultButton 1, "ERROR ON ENTRY!")
    ' ' txtFrom.SetFocu s
    ' ' cmdSave.Enabled = False
    ' ' cmdCancel.Enabl ed = False
    '
    ' Exit Sub
    '
    '
    '
    'End If



    Call GetDataForPerso nalInfoRecord
    Call GetDataForAppli cationRecord

    '
    ' If EditFlag = False Then
    Call ModApplication. AddNew(myPerson alInfoRecord, myApplicationRe cord)
    ' Call ModApplication. AddNew(myPerson alInfoRecord)
    ' Else
    ' Call ModApplication. Update(newAppli cationRecord)
    ' End If
    '
    'Call Init
    '
    ' CourseID = 0
    '
    'PersonalInfoID = 0
    ' SchoolYearID = 0

    End Sub

    Private Sub Form_Load()

    Call Init
    Call InitCbo
    Call currentSY

    ActiveSchoolYea rID = CESDBConn.Execu te("SELECT `t_schoolyear`. `SYFrom`,`t_sch oolyear`.`SYTo` FROM `t_schoolyear`W HERE (`Active` LIKE '1')")



    End Sub

    Sub GetDataForAppli cationRecord()

    With myApplicationRe cord

    .PersonalInfoID = PersonalInfoID
    .DateOfApplicat ion = DTPDateReg.Valu e
    .SchoolLastAtte nded = txtSchoolLastAt nd.Text
    .SLAAddress = txtSchoolAddres sLastAttend.Tex t
    .GeneralAverage = txtHSGenAve.Tex t
    .CourseID = CourseID 'txtCourseAppli ed.Text
    .SchoolYearID = ActiveSchoolYea rID


    End With




    End Sub




    Sub GetDataForPerso nalInfoRecord()


    With myPersonalInfoR ecord

    .FName = txtFName.Text
    .MI = txtMI.Text
    .LName = txtLName.Text
    .BirthDate = txtDateOfBirth. Text
    .PlaceOfBirth = txtPlaceOfBirth .Text
    .Age = txtAge.Text
    .Gender = cboGender.Text
    .HomeAddress = txtHomeAdd.Text
    .ContactPerson = txtContactPerso n.Text
    .ContactPersonP hone = txtContactNumbe r.Text
    .Father = txtFather.Text
    .Mother = txtMother.Text
    .HSDateGraduate d = txtHSYearGrad.T ext



    End With
    End Sub

    Sub Init()

    'Call cleartxtbox(Me)
    'Call Disabledtxt(Me)
    Call Lockedtxt(Me)
    Call DisabledCombo(M e)
    Call DisabledListBox (Me)
    Call clearlistbox(Me )

    DTPDateReg.Valu e = Now
    DTPDateReg.Enab led = False


    cmdEdit.Enabled = False
    cmdSave.Enabled = False
    cmdCancel.Enabl ed = False
    cmdCourseDown.E nabled = False




    End Sub

    Private Sub InitCbo()

    cboGender.AddIt em "Male"
    cboGender.AddIt em "Female"

    End Sub


    Private Sub lstCourse_Click ()
    txtCourseApplie d = lstCourse.Selec tedItem.SubItem s(1)
    txtMajorCourse = lstCourse.Selec tedItem.SubItem s(2)
    CourseID = lstCourse.Selec tedItem.Text

    fraSearch.Visib le = False
    End Sub

    Private Sub textSearchMajor _Change()
    Dim rsCourse As New ADODB.Recordset

    lstCourse.ListI tems.Clear
    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`)WHERE (`Major` LIKE '" & textSearchMajor & "%')", rsCourse)


    End Sub

    Private Sub txtDateOfBirth_ LostFocus()




    If txtDateOfBirth. Text = "" Then

    Call MsgBox("Please Fill up blank fields", vbOKOnly + vbExclamation + vbApplicationMo dal + vbDefaultButton 1, "ERROR ON ENTRY!")
    ' cmdSave.Enabled = False
    ' cmdCancel.Enabl ed = False
    ' txtFrom.SetFocu s
    Exit Sub

    'ElseIf txtDateOfBirth. Text > Format(Now, "MM/dd/yyyy") Then
    '
    ' Call MsgBox("Please Fill up correct birthday", vbOKOnly + vbExclamation + vbApplicationMo dal + vbDefaultButton 1, "ERROR ON ENTRY!")
    ' ' cmdSave.Enabled = False
    ' ' cmdCancel.Enabl ed = False
    ' ' txtFrom.SetFocu s
    ' Exit Sub
    '
    'ElseIf txtDateOfBirth. Text < 10 Then
    '
    ' Call MsgBox("Please Fill up right date format", vbOKOnly + vbExclamation + vbApplicationMo dal + vbDefaultButton 1, "ERROR ON ENTRY!")
    '' cmdSave.Enabled = False
    '' cmdCancel.Enabl ed = False
    '' txtFrom.SetFocu s
    ' Exit Sub
    '
    '
    End If
    date1 = Format(Now, "MM/dd/yyyy")
    date2 = txtDateOfBirth. Text '#6/2/1988#

    Mint = DateDiff("yyyy" , date2, date1)
    txtAge.Text = "" & Mint
    Mint = DateDiff("yyyy" , date2, date1)
    End Sub

    Private Sub txtSearch_Chang e()

    Dim rsCourse As New ADODB.Recordset

    lstCourse.ListI tems.Clear
    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`)WHERE (`CourseName` LIKE '" & txtSearch.Text & "%')", rsCourse)


    End Sub




    'Sub checkdateReg()
    '
    'If DTPDateReg.Valu e < 1907 Then
    '
    ' Call MsgBox(" Please input a year not less than 1907", vbOKOnly + vbExclamation + vbApplicationMo dal + vbDefaultButton 1, "ERROR ON ENTRY!")
    ' ' txtFrom.SetFocu s
    ' ' cmdSave.Enabled = False
    ' ' cmdCancel.Enabl ed = False
    '
    ' Exit Sub
    '
    '
    'ElseIf DTPDateReg.Valu e > Format(Now, "mm/dd/yyyy") Then
    '
    ' Call MsgBox(" Please input a year not greater than the current", vbOKOnly + vbExclamation + vbApplicationMo dal + vbDefaultButton 1, "ERROR ON ENTRY!")
    ' ' txtFrom.SetFocu s
    ' ' cmdSave.Enabled = False
    ' ' cmdCancel.Enabl ed = False
    '
    ' Exit Sub
    '
    '
    '
    'End If
    '
    '
    '
    '
    'End Sub

    Sub currentSY()

    ActiveSchoolYea rFrom = CESDBConn.Execu te("SELECT `t_schoolyear`. `SYFrom`,`t_sch oolyear`.`Activ e`FRO M `t_schoolyear`W HERE (`Active` = '1')").Fields(" SYFrom")
    ActiveSchoolYea rTo = CESDBConn.Execu te("SELECT `t_schoolyear`. `SYTo`,`t_schoo lyear`.`Active` FROM `t_schoolyear`W HERE (`Active` = '1')").Fields(" SYTo")

    lblCurrentSy.Ca ption = ActiveSchoolYea rFrom & " - " & ActiveSchoolYea rTo

    End Sub



    here : ModApplication codes

    _______________ _______________ _______________ _____ _____________-


    Public Type Application


    '************** *************** *** Application *************** *************** ******

    PersonalInfoID As Long
    DateOfApplicati on As String
    SchoolLastAtten ded As String
    SLAAddress As String
    GeneralAverage As Long
    CourseID As Long
    SchoolYearID As String

    End Type


    Public Type PersonalInfo

    '************** *************** *** Personal Info *************** *************** ******

    FName As String
    MI As String
    LName As String
    BirthDate As String
    PlaceOfBirth As String
    Age As Integer
    Gender As String
    HomeAddress As String
    ContactPerson As String
    ContactPersonPh one As Long
    Father As String
    Mother As String
    HSDateGraduated As String

    End Type





    Sub AddNew(myPerson alInfoRecord As PersonalInfo, myApplicationRe cord As Application)



    With myPersonalInfoR ecord


    If CESDBConn.Execu te("SELECT `t_personalinfo `.`FName`,`t_pe rsonalinfo`.`MI `,`t_ personalinfo`.` LName`,`t_perso nalinfo`.`Birth Date` ,`t_personalinf o`.`PlaceOfBirt h`,`t_personali nfo`. `Age`,`t_person alinfo`.`Gender `,`t_personalin fo`.` HomeAddress`,`t _personalinfo`. `ContactPerson` ,`t_p ersonalinfo`.`C ontactPersonPho ne`,`t_personal info` .`Father`,`t_pe rsonalinfo`.`Mo ther`,`t_person alinf o`.`HSDateGradu ated`FROM `t_personalinfo `WHERE (`FName` LIKE '" & .FName & "') AND (`MI` LIKE '" & .MI & "') AND (`LName` LIKE '" & .LName & "') AND (`BirthDate` LIKE '" & .BirthDate & "') AND (`PlaceOfBirth` LIKE '" & .PlaceOfBirth & "') AND (`Age` LIKE '" & .Age & "') AND (`Gender` LIKE '" & .Gender & "') AND (`ContactPerson ` LIKE '" & .ContactPerson & "') AND (`ContactPerson Phone` LIKE '" & .ContactPersonP hone & "') AND (`Father` LIKE '" & .Father & "') AND (`Mother` LIKE '" & .Mother & "') AND (`HSDateGraduat ed` LIKE '" & .HSDateGraduate d & "')").EOF Then

    CESDBConn.Execu te "INSERT INTO `t_personalinfo ` (`FName`, `MI`, `LName`, `BirthDate`, `PlaceOfBirth`, `Age`, `Gender`, `HomeAddress`, `ContactPerson` , `ContactPersonP hone`, `Father`, `Mother`, `HSDateGraduate d`)" & _
    " VALUES('" & .FName & "', '" & .MI & "', '" & .LName & "', '" & .BirthDate & "', '" & .PlaceOfBirth & "', '" & .Age & "', '" & .Gender & "', '" & .HomeAddress & "', '" & .ContactPerson & "', '" & .ContactPersonP hone & "', '" & .Father & "', '" & .Mother & "', '" & .HSDateGraduate d & "')" '

    End If




    End With

    With myApplicationRe cord

    If CESDBConn.Execu te("SELECT `t_application` .`PersonalInfoI D`,`t_applicati on`.` DateOfApplicati on`,`t_applicat ion`.`SchoolLas tAtte nded`,`t_applic ation`.`SLAAddr ess`,`t_applica tion` .`GeneralAverag e`,`t_applicati on`.`CourseID`, `t_ap plication`.`Sch oolYearID`FROM `t_application` WHERE (`t_application `.`PersonalInfo ID` LIKE '" & .PersonalInfoID & "') AND (`DateOfApplica tion` LIKE '" & .DateOfApplicat ion & "') AND (`SchoolLastAtt ended` LIKE '" & .SchoolLastAtte nded & "') AND (`SLAAddress` LIKE '" & .SLAAddress & "') AND (`GeneralAverag e` LIKE '" & .GeneralAverage & "') AND (`CourseID` LIKE '" & .CourseID & "') AND (`SchoolYearID` LIKE '" & .SchoolYearID & "') ").EOF Then

    CESDBConn.Execu te " INSERT INTO `t_application` (`PersonalInfoI D`, `DateOfApplicat ion`, `SchoolLastAtte nded`, `SLAAddress`, `GeneralAverage `, `CourseID`, `SchoolYearID`) " & _
    "VALUES ('" & .PersonalInfoID & "', '" & .DateOfApplicat ion & "', '" & .SchoolLastAtte nded & "', '" & .SLAAddress & "', '" & .GeneralAverage & "','" & .CourseID & "','" & .SchoolYearID & "')"

    End If


    End With



    End Sub





    _______________ _______________ _______________ _____ _____________


    Please help ,thanks you so much...God bless
  • QVeen72
    Recognized Expert Top Contributor
    • Oct 2006
    • 1445

    #2
    Hi,

    Can you Highlight the part where you are getting Error....?

    Regards
    Veena

    Comment

    Working...