Below is my code in my frmApplicantsEntry:
__________________________________________________ _______________
Expand|Select|Wrap|Line Numbers
- Private Mint As Integer
- Dim date1 As Date
- Dim date2 As Date
- Dim myApplicationRecord As Application
- Dim myPersonalInfoRecord As PersonalInfo
- Dim EditFlag As Boolean
- Dim CourseID As Long
- Dim ApplicationID As Long
- Dim PersonalInfoID As Long
- Dim ActiveSchoolYearFrom As String, ActiveSchoolYearTo As String
- Dim ActiveSchoolYearID 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)
- txtCourseApplied.SetFocus
- DTPDateReg.Enabled = True
- txtAge.Locked = True
- cmdAdd.Enabled = False
- cmdEdit.Enabled = True
- cmdSave.Enabled = True
- cmdCancel.Enabled = True
- cmdCourseDown.Enabled = True
- End Sub
- Private Sub cmdCancel_Click()
- Call cleartxtbox(Me)
- End Sub
- Private Sub cmdCourseDown_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)
- End Sub
- Private Sub cmdEdit_Click()
- Call UnLockedtxt(Me)
- End Sub
- Private Sub cmdSave_Click()
- 'If DTPDateReg.Value < 1907 Then
- '
- ' Call MsgBox(" Please input a year not less than 1907", vbOKOnly + vbExclamation + vbApplicationModal + vbDefaultButton1, "ERROR ON ENTRY!")
- ' ' txtFrom.SetFocus
- ' ' cmdSave.Enabled = False
- ' ' cmdCancel.Enabled = False
- '
- ' Exit Sub
- '
- '
- 'ElseIf DTPDateReg.Value > Format(Now, "mm/dd/yyyy") Then
- '
- ' Call MsgBox(" Please input a year not greater than the current", vbOKOnly + vbExclamation + vbApplicationModal + vbDefaultButton1, "ERROR ON ENTRY!")
- ' ' txtFrom.SetFocus
- ' ' cmdSave.Enabled = False
- ' ' cmdCancel.Enabled = False
- '
- ' Exit Sub
- '
- '
- '
- 'End If
- Call GetDataForPersonalInfoRecord
- Call GetDataForApplicationRecord
- '
- ' If EditFlag = False Then
- Call ModApplication.AddNew(myPersonalInfoRecord, myApplicationRecord)
- ' Call ModApplication.AddNew(myPersonalInfoRecord)
- ' Else
- ' Call ModApplication.Update(newApplicationRecord)
- ' End If
- '
- 'Call Init
- '
- ' CourseID = 0
- '
- 'PersonalInfoID = 0
- ' SchoolYearID = 0
- End Sub
- Private Sub Form_Load()
- Call Init
- Call InitCbo
- Call currentSY
- ActiveSchoolYearID = CESDBConn.Execute("SELECT `t_schoolyear`.`SYFrom`,`t_schoolyear`.`SYTo`FROM `t_schoolyear`WHERE (`Active` LIKE '1')")
- End Sub
- Sub GetDataForApplicationRecord()
- With myApplicationRecord
- .PersonalInfoID = PersonalInfoID
- .DateOfApplication = DTPDateReg.Value
- .SchoolLastAttended = txtSchoolLastAtnd.Text
- .SLAAddress = txtSchoolAddressLastAttend.Text
- .GeneralAverage = txtHSGenAve.Text
- .CourseID = CourseID 'txtCourseApplied.Text
- .SchoolYearID = ActiveSchoolYearID
- End With
- End Sub
- Sub GetDataForPersonalInfoRecord()
- With myPersonalInfoRecord
- .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 = txtContactPerson.Text
- .ContactPersonPhone = txtContactNumber.Text
- .Father = txtFather.Text
- .Mother = txtMother.Text
- .HSDateGraduated = txtHSYearGrad.Text
- End With
- End Sub
- Sub Init()
- 'Call cleartxtbox(Me)
- 'Call Disabledtxt(Me)
- Call Lockedtxt(Me)
- Call DisabledCombo(Me)
- Call DisabledListBox(Me)
- Call clearlistbox(Me)
- DTPDateReg.Value = Now
- DTPDateReg.Enabled = False
- cmdEdit.Enabled = False
- cmdSave.Enabled = False
- cmdCancel.Enabled = False
- cmdCourseDown.Enabled = False
- End Sub
- Private Sub InitCbo()
- cboGender.AddItem "Male"
- cboGender.AddItem "Female"
- End Sub
- Private Sub lstCourse_Click()
- txtCourseApplied = lstCourse.SelectedItem.SubItems(1)
- txtMajorCourse = lstCourse.SelectedItem.SubItems(2)
- CourseID = lstCourse.SelectedItem.Text
- fraSearch.Visible = False
- End Sub
- Private Sub textSearchMajor_Change()
- Dim rsCourse As New ADODB.Recordset
- lstCourse.ListItems.Clear
- 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`)
- WHERE (`Major` LIKE '" & textSearchMajor & "%')", rsCourse)
- End Sub
- Private Sub txtDateOfBirth_LostFocus()
- If txtDateOfBirth.Text = "" Then
- Call MsgBox("Please Fill up blank fields", vbOKOnly + vbExclamation + vbApplicationModal + vbDefaultButton1, "ERROR ON ENTRY!")
- ' cmdSave.Enabled = False
- ' cmdCancel.Enabled = False
- ' txtFrom.SetFocus
- Exit Sub
- 'ElseIf txtDateOfBirth.Text > Format(Now, "MM/dd/yyyy") Then
- '
- ' Call MsgBox("Please Fill up correct birthday", vbOKOnly + vbExclamation + vbApplicationModal + vbDefaultButton1, "ERROR ON ENTRY!")
- ' ' cmdSave.Enabled = False
- ' ' cmdCancel.Enabled = False
- ' ' txtFrom.SetFocus
- ' Exit Sub
- '
- 'ElseIf txtDateOfBirth.Text < 10 Then
- '
- ' Call MsgBox("Please Fill up right date format", vbOKOnly + vbExclamation + vbApplicationModal + vbDefaultButton1, "ERROR ON ENTRY!")
- '' cmdSave.Enabled = False
- '' cmdCancel.Enabled = False
- '' txtFrom.SetFocus
- ' 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_Change()
- Dim rsCourse As New ADODB.Recordset
- lstCourse.ListItems.Clear
- 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`)
- WHERE (`CourseName` LIKE '" & txtSearch.Text & "%')", rsCourse)
- End Sub
- 'Sub checkdateReg()
- '
- 'If DTPDateReg.Value < 1907 Then
- '
- ' Call MsgBox(" Please input a year not less than 1907", vbOKOnly + vbExclamation + vbApplicationModal + vbDefaultButton1, "ERROR ON ENTRY!")
- ' ' txtFrom.SetFocus
- ' ' cmdSave.Enabled = False
- ' ' cmdCancel.Enabled = False
- '
- ' Exit Sub
- '
- '
- 'ElseIf DTPDateReg.Value > Format(Now, "mm/dd/yyyy") Then
- '
- ' Call MsgBox(" Please input a year not greater than the current", vbOKOnly + vbExclamation + vbApplicationModal + vbDefaultButton1, "ERROR ON ENTRY!")
- ' ' txtFrom.SetFocus
- ' ' cmdSave.Enabled = False
- ' ' cmdCancel.Enabled = False
- '
- ' Exit Sub
- '
- '
- '
- 'End If
- '
- '
- '
- '
- 'End Sub
- Sub currentSY()
- ActiveSchoolYearFrom = CESDBConn.Execute("SELECT `t_schoolyear`.`SYFrom`,`t_schoolyear`.`Active`FROM `t_schoolyear`WHERE (`Active` = '1')").Fields("SYFrom")
- ActiveSchoolYearTo = CESDBConn.Execute("SELECT `t_schoolyear`.`SYTo`,`t_schoolyear`.`Active`FROM `t_schoolyear`WHERE (`Active` = '1')").Fields("SYTo")
- lblCurrentSy.Caption = ActiveSchoolYearFrom & " - " & ActiveSchoolYearTo
- End Sub
- here : ModApplication codes
- _______________________________________________________________-
- Public Type Application
- '******************************** Application ************************************
- PersonalInfoID As Long
- DateOfApplication As String
- SchoolLastAttended 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
- ContactPersonPhone As Long
- Father As String
- Mother As String
- HSDateGraduated As String
- End Type
- Sub AddNew(myPersonalInfoRecord As PersonalInfo, myApplicationRecord As Application)
- With myPersonalInfoRecord
- If CESDBConn.Execute("SELECT `t_personalinfo`.`FName`,`t_personalinfo`.`MI`,`t_personalinfo`.`LName`,`t_personalinfo`.`BirthDate`,`t_personalinfo`.`PlaceOfBirth`,`t_personalinfo`.`Age`,`t_personalinfo`.`Gender`,`t_personalinfo`.`HomeAddress`,`t_personalinfo`.`ContactPerson`,`t_personalinfo`.`ContactPersonPhone`,`t_personalinfo`.`Father`,`t_personalinfo`.`Mother`,`t_personalinfo`.`HSDateGraduated`
- 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 (`ContactPersonPhone` LIKE '" & .ContactPersonPhone & "')
- AND (`Father` LIKE '" & .Father & "') AND (`Mother` LIKE '" & .Mother & "')
- AND (`HSDateGraduated` LIKE '" & .HSDateGraduated & "')").EOF Then
- CESDBConn.Execute "INSERT INTO `t_personalinfo` (`FName`, `MI`, `LName`, `BirthDate`, `PlaceOfBirth`, `Age`, `Gender`, `HomeAddress`, `ContactPerson`, `ContactPersonPhone`, `Father`, `Mother`, `HSDateGraduated`)" & _
- " VALUES('" & .FName & "', '" & .MI & "', '" & .LName & "', '" & .BirthDate & "', '" & .PlaceOfBirth & "', '" & .Age & "', '" & .Gender & "', '" & .HomeAddress & "', '" & .ContactPerson & "', '" & .ContactPersonPhone & "', '" & .Father & "', '" & .Mother & "', '" & .HSDateGraduated & "')" '
- End If
- End With
- With myApplicationRecord
- If CESDBConn.Execute("SELECT `t_application`.`PersonalInfoID`,`t_application`.`DateOfApplication`,`t_application`.`SchoolLastAttended`,`t_application`.`SLAAddress`,`t_application`.`GeneralAverage`,`t_application`.`CourseID`,`t_application`.`SchoolYearID`
- FROM `t_application`
- WHERE (`t_application`.`PersonalInfoID` LIKE '" & .PersonalInfoID & "')
- AND (`DateOfApplication` LIKE '" & .DateOfApplication & "')
- AND (`SchoolLastAttended` LIKE '" & .SchoolLastAttended & "')
- AND (`SLAAddress` LIKE '" & .SLAAddress & "')
- AND (`GeneralAverage` LIKE '" & .GeneralAverage & "')
- AND (`CourseID` LIKE '" & .CourseID & "')
- AND (`SchoolYearID` LIKE '" & .SchoolYearID & "') ").EOF Then
- CESDBConn.Execute " INSERT INTO `t_application` (`PersonalInfoID`, `DateOfApplication`, `SchoolLastAttended`, `SLAAddress`, `GeneralAverage`, `CourseID`, `SchoolYearID`)" & _
- "VALUES ('" & .PersonalInfoID & "', '" & .DateOfApplication & "', '" & .SchoolLastAttended & "', '" & .SLAAddress & "', '" & .GeneralAverage & "','" & .CourseID & "','" & .SchoolYearID & "')"
- End If
- End With
- End Sub
__________________________________________________ _____________
Please help ,thanks you so much...God bless