'===========================================================================
'Start Code for upload photo and this code will be always placed on top
'===========================================================================
Dim fpath As String
'=============================================================================================================================
'Start code for select only from ComboBox (Copy the source code from https://www.MSexcelvba.com) and use for TextBox or ComboBox.
'=============================================================================================================================
Private Sub ComboBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
'============================
'Select only from ComboBox1
'============================
On Error Resume Next
If (KeyAscii > 500 And KeyAscii < 500) Or KeyAscii = 45 Or KeyAscii = 46 Then
KeyAscii = KeyAscii
Else
KeyAscii = 0
MsgBox "Invalid Key Pressed, You Can Select Only", vbOKOnly, "Learn with MSexcelvba.com"
End If
End Sub
Private Sub ComboBox2_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
'============================
'Select only from ComboBox2
'============================
On Error Resume Next
If (KeyAscii > 500 And KeyAscii < 500) Or KeyAscii = 45 Or KeyAscii = 46 Then
KeyAscii = KeyAscii
Else
KeyAscii = 0
MsgBox "Invalid Key Pressed, You Can Select Only", vbOKOnly, "Learn with MSexcelvba.com"
End If
End Sub
Private Sub ComboBox3_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
'============================
'Select only from ComboBox3
'============================
On Error Resume Next
If (KeyAscii > 500 And KeyAscii < 500) Or KeyAscii = 45 Or KeyAscii = 46 Then
KeyAscii = KeyAscii
Else
KeyAscii = 0
MsgBox "Invalid Key Pressed, You Can Select Only", vbOKOnly, "Learn with MSexcelvba.com"
End If
End Sub
Private Sub ComboBox4_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
'============================
'Select only from ComboBox4
'============================
On Error Resume Next
If (KeyAscii > 500 And KeyAscii < 500) Or KeyAscii = 45 Or KeyAscii = 46 Then
KeyAscii = KeyAscii
Else
KeyAscii = 0
MsgBox "Invalid Key Pressed, You Can Select Only", vbOKOnly, "Learn with MSexcelvba.com"
End If
End Sub
Private Sub ComboBox5_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
'============================
'Select only from ComboBox5
'============================
On Error Resume Next
If (KeyAscii > 500 And KeyAscii < 500) Or KeyAscii = 45 Or KeyAscii = 46 Then
KeyAscii = KeyAscii
Else
KeyAscii = 0
MsgBox "Invalid Key Pressed, You Can Select Only", vbOKOnly, "Learn with MSexcelvba.com"
End If
End Sub
Private Sub ComboBox6_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
'============================
'Select only from ComboBox6
'============================
On Error Resume Next
If (KeyAscii > 500 And KeyAscii < 500) Or KeyAscii = 45 Or KeyAscii = 46 Then
KeyAscii = KeyAscii
Else
KeyAscii = 0
MsgBox "Invalid Key Pressed, You Can Select Only", vbOKOnly, "Learn with MSexcelvba.com"
End If
End Sub
Private Sub ComboBox7_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
'============================
'Select only from ComboBox7
'============================
On Error Resume Next
If (KeyAscii > 500 And KeyAscii < 500) Or KeyAscii = 45 Or KeyAscii = 46 Then
KeyAscii = KeyAscii
Else
KeyAscii = 0
MsgBox "Invalid Key Pressed, You Can Select Only", vbOKOnly, "Learn with MSexcelvba.com"
End If
End Sub
Private Sub ComboBox8_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
'============================
'Select only from ComboBox8
'============================
On Error Resume Next
If (KeyAscii > 500 And KeyAscii < 500) Or KeyAscii = 45 Or KeyAscii = 46 Then
KeyAscii = KeyAscii
Else
KeyAscii = 0
MsgBox "Invalid Key Pressed, You Can Select Only", vbOKOnly, "Learn with MSexcelvba.com"
End If
End Sub
Private Sub ComboBox9_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
'============================
'Select only from ComboBox9
'============================
On Error Resume Next
If (KeyAscii > 500 And KeyAscii < 500) Or KeyAscii = 45 Or KeyAscii = 46 Then
KeyAscii = KeyAscii
Else
KeyAscii = 0
MsgBox "Invalid Key Pressed, You Can Select Only", vbOKOnly, "Learn with MSexcelvba.com"
End If
End Sub
Private Sub ComboBox10_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
'============================
'Select only from ComboBox10
'============================
On Error Resume Next
If (KeyAscii > 500 And KeyAscii < 500) Or KeyAscii = 45 Or KeyAscii = 46 Then
KeyAscii = KeyAscii
Else
KeyAscii = 0
MsgBox "Invalid Key Pressed, You Can Select Only", vbOKOnly, "Learn with MSexcelvba.com"
End If
End Sub
Private Sub ComboBox11_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
'============================
'Select only from ComboBox11
'============================
On Error Resume Next
If (KeyAscii > 500 And KeyAscii < 500) Or KeyAscii = 45 Or KeyAscii = 46 Then
KeyAscii = KeyAscii
Else
KeyAscii = 0
MsgBox "Invalid Key Pressed, You Can Select Only", vbOKOnly, "Learn with MSexcelvba.com"
End If
End Sub
Private Sub ComboBox12_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
'============================
'Select only from ComboBox12
'============================
On Error Resume Next
If (KeyAscii > 500 And KeyAscii < 500) Or KeyAscii = 45 Or KeyAscii = 46 Then
KeyAscii = KeyAscii
Else
KeyAscii = 0
MsgBox "Invalid Key Pressed, You Can Select Only", vbOKOnly, "Learn with MSexcelvba.com"
End If
End Sub
Private Sub ComboBox13_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
'============================
'Select only from ComboBox13
'============================
On Error Resume Next
If (KeyAscii > 500 And KeyAscii < 500) Or KeyAscii = 45 Or KeyAscii = 46 Then
KeyAscii = KeyAscii
Else
KeyAscii = 0
MsgBox "Invalid Key Pressed, You Can Select Only", vbOKOnly, "Learn with MSexcelvba.com"
End If
End Sub
Private Sub ComboBox14_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
'============================
'Select only from ComboBox14
'============================
On Error Resume Next
If (KeyAscii > 500 And KeyAscii < 500) Or KeyAscii = 45 Or KeyAscii = 46 Then
KeyAscii = KeyAscii
Else
KeyAscii = 0
MsgBox "Invalid Key Pressed, You Can Select Only", vbOKOnly, "Learn with MSexcelvba.com"
End If
End Sub
Private Sub ComboBox15_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
'============================
'Select only from ComboBox15
'============================
On Error Resume Next
If (KeyAscii > 500 And KeyAscii < 500) Or KeyAscii = 45 Or KeyAscii = 46 Then
KeyAscii = KeyAscii
Else
KeyAscii = 0
MsgBox "Invalid Key Pressed, You Can Select Only", vbOKOnly, "Learn with MSexcelvba.com"
End If
End Sub
Private Sub ComboBox16_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
'============================
'Select only from ComboBox16
'============================
On Error Resume Next
If (KeyAscii > 500 And KeyAscii < 500) Or KeyAscii = 45 Or KeyAscii = 46 Then
KeyAscii = KeyAscii
Else
KeyAscii = 0
MsgBox "Invalid Key Pressed, You Can Select Only", vbOKOnly, "Learn with MSexcelvba.com"
End If
End Sub
Private Sub ComboBox17_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
'============================
'Select only from ComboBox17
'============================
On Error Resume Next
If (KeyAscii > 500 And KeyAscii < 500) Or KeyAscii = 45 Or KeyAscii = 46 Then
KeyAscii = KeyAscii
Else
KeyAscii = 0
MsgBox "Invalid Key Pressed, You Can Select Only", vbOKOnly, "Learn with MSexcelvba.com"
End If
End Sub
Private Sub ComboBox18_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
'============================
'Select only from ComboBox18
'============================
On Error Resume Next
If (KeyAscii > 500 And KeyAscii < 500) Or KeyAscii = 45 Or KeyAscii = 46 Then
KeyAscii = KeyAscii
Else
KeyAscii = 0
MsgBox "Invalid Key Pressed, You Can Select Only", vbOKOnly, "Learn with MSexcelvba.com"
End If
End Sub
Private Sub CommandButton10_Click()
Unload Me
Admission.Show
End Sub
Private Sub CommandButton11_Click()
Unload Me
End Sub
'========================================================
'End code for select only from ComboBox
'========================================================
Private Sub CommandButton6_Click()
'===========================================================================
'Start Code for upload photo (This code use for upload button)
'===========================================================================
On Error Resume Next
Dim x As Integer
Application.FileDialog(msoFileDialogOpen).AllowMultiSelect = False
x = Application.FileDialog(msoFileDialogOpen).Show
If x <> 0 Then
fpath = Application.FileDialog(msoFileDialogOpen).SelectedItems(1)
Image1.Picture = LoadPicture(fpath)
Image1.PictureSizeMode = 1
End If
End Sub
'===========================================================================
'Start Code for upload photo
'===========================================================================
Private Sub CommandButton7_Click()
'=========================================================================================================================
'=========================================================================================================================
'==================================
'Required field for Student Name
'==================================
On Error Resume Next
If TextBox2.text = "" Then
Cancel = 1
MsgBox "Please enter the student name", vbOKOnly, "Learn with MSexcelvba.Com"
TextBox2.SetFocus
Exit Sub
End If
'==================================
'Required field for Father's Name
'==================================
On Error Resume Next
If TextBox3.text = "" Then
Cancel = 1
MsgBox "Please enter the Father's Name", vbOKOnly, "Learn with MSexcelvba.Com"
TextBox3.SetFocus
Exit Sub
End If
'==================================
'Required field for Mother's Name
'==================================
On Error Resume Next
If TextBox4.text = "" Then
Cancel = 1
MsgBox "Please enter the Mother's name", vbOKOnly, "Learn with MSexcelvba.Com"
TextBox4.SetFocus
Exit Sub
End If
'==================================
'Required field for Student Date Of Birth
'==================================
On Error Resume Next
If TextBox5.text = "" Then
Cancel = 1
MsgBox "Please enter the student's Date of Birth", vbOKOnly, "Learn with MSexcelvba.Com"
TextBox5.SetFocus
Exit Sub
End If
'==================================
'Required field for Student's Adhar Card No
'==================================
On Error Resume Next
If TextBox7.text = "" Then
Cancel = 1
MsgBox "Please enter the student's Adhar No.", vbOKOnly, "Learn with MSexcelvba.Com"
TextBox7.SetFocus
Exit Sub
End If
'==================================
'Required field for Student's Identification Mark
'==================================
On Error Resume Next
If TextBox15.text = "" Then
Cancel = 1
MsgBox "Please enter the student's Identification Mark", vbOKOnly, "Learn with MSexcelvba.Com"
TextBox15.SetFocus
Exit Sub
End If
'==================================
'Required field for Mobile No1.
'==================================
On Error Resume Next
If TextBox37.text = "" Then
Cancel = 1
MsgBox "Please enter the Mobile No.1", vbOKOnly, "Learn with MSexcelvba.Com"
TextBox37.SetFocus
Exit Sub
End If
'==================================
'Required field for Mobile No2.
'==================================
On Error Resume Next
If TextBox13.text = "" Then
Cancel = 1
MsgBox "Please enter the Mobile No.2", vbOKOnly, "Learn with MSexcelvba.Com"
TextBox13.SetFocus
Exit Sub
End If
'==================================
'Required field for Whats App No..
'==================================
On Error Resume Next
If TextBox38.text = "" Then
Cancel = 1
MsgBox "Please enter the What's App No.", vbOKOnly, "Learn with MSexcelvba.Com"
TextBox38.SetFocus
Exit Sub
End If
'==================================
'Required field for Parmanent Address.
'==================================
On Error Resume Next
If TextBox8.text = "" Then
Cancel = 1
MsgBox "Please enter the Parmanent Address", vbOKOnly, "Learn with MSexcelvba.Com"
TextBox8.SetFocus
Exit Sub
End If
'==================================
'Required field for Present Address.
'==================================
On Error Resume Next
If TextBox14.text = "" Then
Cancel = 1
MsgBox "Please enter the Present Address", vbOKOnly, "Learn with MSexcelvba.Com"
TextBox14.SetFocus
Exit Sub
End If
'==================================
'Required field for Registration No.
'==================================
On Error Resume Next
If TextBox39.text = "" Then
Cancel = 1
MsgBox "Please enter the Registration No.", vbOKOnly, "Learn with MSexcelvba.Com"
TextBox39.SetFocus
Exit Sub
End If
'==================================
'Required field for Father Name.
'==================================
On Error Resume Next
If TextBox21.text = "" Then
Cancel = 1
MsgBox "Please enter the Father Name", vbOKOnly, "Learn with MSexcelvba.Com"
TextBox21.SetFocus
Exit Sub
End If
'==================================
'Required field for Mother Name.
'==================================
On Error Resume Next
If TextBox26.text = "" Then
Cancel = 1
MsgBox "Please enter the Mother's Name", vbOKOnly, "Learn with MSexcelvba.Com"
TextBox26.SetFocus
Exit Sub
End If
'==================================
'Required field for Father Age.
'==================================
On Error Resume Next
If TextBox22.text = "" Then
Cancel = 1
MsgBox "Please enter the Father Age in Year", vbOKOnly, "Learn with MSexcelvba.Com"
TextBox22.SetFocus
Exit Sub
End If
'==================================
'Required field for Mother Age.
'==================================
On Error Resume Next
If TextBox25.text = "" Then
Cancel = 1
MsgBox "Please enter the Mother Age in Year", vbOKOnly, "Learn with MSexcelvba.Com"
TextBox25.SetFocus
Exit Sub
End If
'==================================
'Required field for Father's Qualification.
'==================================
On Error Resume Next
If TextBox23.text = "" Then
Cancel = 1
MsgBox "Please enter the Qualification of Father", vbOKOnly, "Learn with MSexcelvba.Com"
TextBox23.SetFocus
Exit Sub
End If
'==================================
'Required field for Mother's Qualification of Mother.
'==================================
On Error Resume Next
If TextBox24.text = "" Then
Cancel = 1
MsgBox "Please enter the Mother's Qualification of Mother", vbOKOnly, "Learn with MSexcelvba.Com"
TextBox24.SetFocus
Exit Sub
End If
'==================================
'Required field for Father's Age.
'==================================
On Error Resume Next
If TextBox22.text = "" Then
Cancel = 1
MsgBox "Please enter the Mother's Qualification of Mother", vbOKOnly, "Learn with MSexcelvba.Com"
TextBox22.SetFocus
Exit Sub
End If
'==================================
'Required field for Hight.
'==================================
On Error Resume Next
If TextBox32.text = "" Then
Cancel = 1
MsgBox "Please enter the Hight", vbOKOnly, "Learn with MSexcelvba.Com"
TextBox32.SetFocus
Exit Sub
End If
'==================================
'Required field for Weight.
'==================================
On Error Resume Next
If TextBox33.text = "" Then
Cancel = 1
MsgBox "Please enter the Weight", vbOKOnly, "Learn with MSexcelvba.Com"
TextBox33.SetFocus
Exit Sub
End If
'==================================
'Required field for Sibiling 1 Name.
'==================================
On Error Resume Next
If TextBox17.text = "" Then
Cancel = 1
MsgBox "sibiling 1. name", vbOKOnly, "Learn with MSexcelvba.Com"
TextBox17.SetFocus
Exit Sub
End If
'==================================
'Required field for Sibiling 1 Age.
'==================================
On Error Resume Next
If TextBox18.text = "" Then
Cancel = 1
MsgBox "sibiling 1 Age", vbOKOnly, "Learn with MSexcelvba.Com"
TextBox18.SetFocus
Exit Sub
End If
'==================================
'Required field for sibiling 2 Name.
'==================================
On Error Resume Next
If TextBox19.text = "" Then
Cancel = 1
MsgBox "Please enter the Sibiling 2 Name", vbOKOnly, "Learn with MSexcelvba.Com"
TextBox19.SetFocus
Exit Sub
End If
'==================================
'Required field for sibiling 2 Age.
'==================================
On Error Resume Next
If TextBox20.text = "" Then
Cancel = 1
MsgBox "Please enter the sibiling 2 Age", vbOKOnly, "Learn with MSexcelvba.Com"
TextBox20.SetFocus
Exit Sub
End If
'==================================
'Required field for Detail of Chronoic Disease.
'==================================
On Error Resume Next
If TextBox27.text = "" Then
Cancel = 1
MsgBox "Please enter the Detail of Chromic Disease", vbOKOnly, "Learn with MSexcelvba.Com"
TextBox27.SetFocus
Exit Sub
End If
'==================================
'Required field for Detail of Allergies by Food .
'==================================
On Error Resume Next
If TextBox28.text = "" Then
Cancel = 1
MsgBox "Please enter the Details of Allegries Food", vbOKOnly, "Learn with MSexcelvba.Com"
TextBox28.SetFocus
Exit Sub
End If
'==================================
'Required field for Detail of Allergies by Medicine.
'==================================
On Error Resume Next
If TextBox29.text = "" Then
Cancel = 1
MsgBox "Please enter the Details of Allergies Medicine", vbOKOnly, "Learn with MSexcelvba.Com"
TextBox29.SetFocus
Exit Sub
End If
'==================================
'Required field for Detail of other Document.
'==================================
On Error Resume Next
If TextBox36.text = "" Then
Cancel = 1
MsgBox "Please enter the details of other docoument submitted", vbOKOnly, "Learn with MSexcelvba.Com"
TextBox36.SetFocus
Exit Sub
End If
'==================================
'Required field for cast.
'==================================
On Error Resume Next
If TextBox40.text = "" Then
Cancel = 1
MsgBox "Please enter the Cast", vbOKOnly, "Learn with MSexcelvba.Com"
TextBox40.SetFocus
Exit Sub
End If
'==================================
'Required field for Eye Sight.
'==================================
On Error Resume Next
If TextBox34.text = "" Then
Cancel = 1
MsgBox "Please enter the Eye Sight Detail", vbOKOnly, "Learn with MSexcelvba.Com"
TextBox34.SetFocus
Exit Sub
End If
'==================================
'Required field for Drop & Pick Address.
'==================================
On Error Resume Next
If TextBox35.text = "" Then
Cancel = 1
MsgBox "Please enter the Detail Address of Pick & Drop", vbOKOnly, "Learn with MSexcelvba.Com"
TextBox35.SetFocus
Exit Sub
End If
'==================================
'Required field for Date.
'==================================
On Error Resume Next
If TextBox9.text = "" Then
Cancel = 1
MsgBox "Please enter the Addmission Date", vbOKOnly, "Learn with MSexcelvba.Com"
TextBox9.SetFocus
Exit Sub
End If
'===================================
'Required field for Student Gender
'===================================
On Error Resume Next
If ComboBox1.text = "" Then
Cancel = 1
MsgBox "Please select the student gender", vbOKOnly, "Learn with MSexcelvba.Com"
ComboBox1.SetFocus
Exit Sub
End If
'===================================
'Required field for Class
'===================================
On Error Resume Next
If ComboBox3.text = "" Then
Cancel = 1
MsgBox "Please select the student Class", vbOKOnly, "Learn with MSexcelvba.Com"
ComboBox3.SetFocus
Exit Sub
End If
'===================================
'Required field for Section
'===================================
On Error Resume Next
If ComboBox4.text = "" Then
Cancel = 1
MsgBox "Please select the Class Section", vbOKOnly, "Learn with MSexcelvba.Com"
ComboBox4.SetFocus
Exit Sub
End If
'===================================
'Required field for Religion
'===================================
On Error Resume Next
If ComboBox5.text = "" Then
Cancel = 1
MsgBox "Please select the student Religion", vbOKOnly, "Learn with MSexcelvba.Com"
ComboBox5.SetFocus
Exit Sub
End If
'===================================
'Required field for Student Social Category
'===================================
On Error Resume Next
If ComboBox2.text = "" Then
Cancel = 1
MsgBox "Please select the social Catogary", vbOKOnly, "Learn with MSexcelvba.Com"
ComboBox2.SetFocus
Exit Sub
End If
'===================================
'Required field for Transport Ficility
'===================================
On Error Resume Next
If ComboBox14.text = "" Then
Cancel = 1
MsgBox "Please select the Transport Facility Required or Not", vbOKOnly, "Learn with MSexcelvba.Com"
ComboBox14.SetFocus
Exit Sub
End If
'===================================
'Required field for Alliergies by Food
'===================================
On Error Resume Next
If ComboBox12.text = "" Then
Cancel = 1
MsgBox "Please select the Alliergies by Food Yes or Not", vbOKOnly, "Learn with MSexcelvba.Com"
ComboBox12.SetFocus
Exit Sub
End If
'===================================
'Required field for Allergies by Medicen
'===================================
On Error Resume Next
If ComboBox11.text = "" Then
Cancel = 1
MsgBox "Please select the Alliergies by Medicien Yes or Not", vbOKOnly, "Learn with MSexcelvba.Com"
ComboBox11.SetFocus
Exit Sub
End If
'===================================
'Required field for Colour Recogition
'===================================
On Error Resume Next
If ComboBox13.text = "" Then
Cancel = 1
MsgBox "Please select the Colour Recogition Yes or Not", vbOKOnly, "Learn with MSexcelvba.Com"
ComboBox13.SetFocus
Exit Sub
End If
'===================================
'Required field for Birth Certificate Submitted Yes or Not
'===================================
On Error Resume Next
If ComboBox15.text = "" Then
Cancel = 1
MsgBox "Please select the Birth Certificate Submitted Yes or Not", vbOKOnly, "Learn with MSexcelvba.Com"
ComboBox15.SetFocus
Exit Sub
End If
'===================================
'Required field for Adhar Card Submitted Yes or Not
'===================================
On Error Resume Next
If ComboBox16.text = "" Then
Cancel = 1
MsgBox "Please select the Adhar Card Submitted Yes or Not", vbOKOnly, "Learn with MSexcelvba.Com"
ComboBox16.SetFocus
Exit Sub
End If
'===================================
'Required field for TC/Passing Certificate Submitted Yes or Not
'===================================
On Error Resume Next
If ComboBox17.text = "" Then
Cancel = 1
MsgBox "Please select the TC/Passing Certificate Submitted Yes or Not", vbOKOnly, "Learn with MSexcelvba.Com"
ComboBox17.SetFocus
Exit Sub
End If
'===================================
'Required field for Address Proof Submitted Yes or Not
'===================================
On Error Resume Next
If ComboBox18.text = "" Then
Cancel = 1
MsgBox "Please select the Address Proof Submitted Yes or Not", vbOKOnly, "Learn with MSexcelvba.Com"
ComboBox18.SetFocus
Exit Sub
End If
'===================================
'Required field for Sibiling 1 Class
'===================================
On Error Resume Next
If ComboBox7.text = "" Then
Cancel = 1
MsgBox "Please select the Sibiling 1 Class", vbOKOnly, "Learn with MSexcelvba.Com"
ComboBox7.SetFocus
Exit Sub
End If
'===================================
'Required field for Sibiling Sibiling 2 Class
'===================================
On Error Resume Next
If ComboBox8.text = "" Then
Cancel = 1
MsgBox "Please select the Sibiling 2 Class", vbOKOnly, "Learn with MSexcelvba.Com"
ComboBox8.SetFocus
Exit Sub
End If
'===================================
'Required field for Chronic Disease
'===================================
On Error Resume Next
If ComboBox9.text = "" Then
Cancel = 1
MsgBox "Please select the Chronic Disease Yes or No", vbOKOnly, "Learn with MSexcelvba.Com"
ComboBox9.SetFocus
Exit Sub
End If
'===================================
'Required field for Chosing Landmark
'===================================
On Error Resume Next
If ComboBox19.text = "" Then
Cancel = 1
MsgBox "Please select the Landmark for transport", vbOKOnly, "Learn with MSexcelvba.Com"
ComboBox19.SetFocus
Exit Sub
End If
'===================================
'Required field for Chosing Student Type
'===================================
On Error Resume Next
If ComboBox20.text = "" Then
Cancel = 1
MsgBox "Please select the Student Type", vbOKOnly, "Learn with MSexcelvba.Com"
ComboBox20.SetFocus
Exit Sub
End If
'=============================================================
'End code for required field
'=============================================================
'========================================================================
'start Code for enter data from Textbox into Database Worksheet
'========================================================================
Dim x As Long
Dim y As Worksheet
Set y = Sheets("Database")
x = y.Range("B" & Rows.Count).End(xlUp).Row
With y
.Cells(x + 1, "E").Value = TextBox2.text
.Cells(x + 1, "L").Value = TextBox3.text
.Cells(x + 1, "M").Value = TextBox4.text
.Cells(x + 1, "G").Value = TextBox5.text
.Cells(x + 1, "H").Value = TextBox7.text
.Cells(x + 1, "T").Value = TextBox8.text
.Cells(x + 1, "D").Value = TextBox9.text
.Cells(x + 1, "B").Value = TextBox10.text
.Cells(x + 1, "C").Value = TextBox12.text
.Cells(x + 1, "R").Value = TextBox13.text
.Cells(x + 1, "U").Value = TextBox14.text
.Cells(x + 1, "I").Value = TextBox15.text
.Cells(x + 1, "V").Value = TextBox17.text
.Cells(x + 1, "W").Value = TextBox18.text
.Cells(x + 1, "Y").Value = TextBox19.text
.Cells(x + 1, "Z").Value = TextBox20.text
.Cells(x + 1, "AB").Value = TextBox21.text
.Cells(x + 1, "AC").Value = TextBox22.text
.Cells(x + 1, "AD").Value = TextBox23.text
.Cells(x + 1, "AG").Value = TextBox24.text
.Cells(x + 1, "Af").Value = TextBox25.text
.Cells(x + 1, "AE").Value = TextBox26.text
.Cells(x + 1, "AI").Value = TextBox27.text
.Cells(x + 1, "AK").Value = TextBox28.text
.Cells(x + 1, "AM").Value = TextBox29.text
.Cells(x + 1, "AN").Value = TextBox32.text
.Cells(x + 1, "AO").Value = TextBox33.text
.Cells(x + 1, "AP").Value = TextBox34.text
.Cells(x + 1, "AS").Value = TextBox35.text
.Cells(x + 1, "AX").Value = TextBox36.text
.Cells(x + 1, "Q").Value = TextBox37.text
.Cells(x + 1, "S").Value = TextBox38.text
.Cells(x + 1, "A").Value = TextBox39.text
.Cells(x + 1, "O").Value = TextBox40.text
.Cells(x + 1, "F").Value = ComboBox1.text
.Cells(x + 1, "P").Value = ComboBox2.text
.Cells(x + 1, "J").Value = ComboBox3.text
.Cells(x + 1, "K").Value = ComboBox4.text
.Cells(x + 1, "N").Value = ComboBox5.text
.Cells(x + 1, "F").Value = ComboBox6.text
.Cells(x + 1, "X").Value = ComboBox7.text
.Cells(x + 1, "AA").Value = ComboBox8.text
.Cells(x + 1, "AH").Value = ComboBox9.text
.Cells(x + 1, "AL").Value = ComboBox11.text
.Cells(x + 1, "AJ").Value = ComboBox12.text
.Cells(x + 1, "AQ").Value = ComboBox13.text
.Cells(x + 1, "AR").Value = ComboBox14.text
.Cells(x + 1, "AT").Value = ComboBox15.text
.Cells(x + 1, "AU").Value = ComboBox16.text
.Cells(x + 1, "AV").Value = ComboBox17.text
.Cells(x + 1, "AW").Value = ComboBox18.text
.Cells(x + 1, "AY").Value = ComboBox19.text
.Cells(x + 1, "AZ").Value = ComboBox20.text
End With
'================================================================
'start code for send uploaded photo in Photo folder of C Drive
'================================================================
On Error Resume Next
Dim i As String
i = TextBox1.text
FileCopy fpath, "C:\Photo\" & i & ".jpg"
'======================================================================================
'start code for clear Textbox after submit data from Textbox into Database Worksheet
'======================================================================================
TextBox2.text = ""
TextBox3.text = ""
TextBox4.text = ""
TextBox5.text = ""
TextBox6.text = ""
TextBox7.text = ""
TextBox8.text = ""
TextBox13.text = ""
TextBox14.text = ""
TextBox15.text = ""
TextBox17.text = ""
TextBox18.text = ""
TextBox19.text = ""
TextBox9.text = ""
TextBox20.text = ""
TextBox21.text = ""
TextBox22.text = ""
TextBox23.text = ""
TextBox24.text = ""
TextBox25.text = ""
TextBox26.text = ""
TextBox27.text = ""
TextBox28.text = ""
TextBox29.text = ""
TextBox32.text = ""
TextBox33.text = ""
TextBox34.text = ""
TextBox35.text = ""
TextBox36.text = ""
TextBox37.text = ""
TextBox38.text = ""
TextBox39.text = ""
TextBox40.text = ""
ComboBox1.text = ""
ComboBox2.text = ""
ComboBox3.text = ""
ComboBox4.text = ""
ComboBox5.text = ""
ComboBox7.text = ""
ComboBox8.text = ""
ComboBox9.text = ""
ComboBox11.text = ""
ComboBox12.text = ""
ComboBox13.text = ""
ComboBox14.text = ""
ComboBox15.text = ""
ComboBox16.text = ""
ComboBox17.text = ""
ComboBox18.text = ""
ComboBox19.text = ""
ComboBox20.text = ""
'=================================================================
'start code for clear uploaded photo after submit
'=================================================================
Image1.Picture = Nothing
'=================================================================
'start code for show message after submit data
'=================================================================
MsgBox "Admission successfully. Now click on the reset button for new admission.", vbOKOnly, "Learn with MSexcelvba.Com"
End Sub
Private Sub CommandButton8_Click()
'============================================
'start code for Search Student Information
'============================================
On Error Resume Next
Dim x As Long
Dim y As Long
x = Sheets("Database").Range("A" & Rows.Count).End(xlUp).Row
For y = 2 To x
If Sheets("Database").Cells(y, 1).text = TextBox41.Value Then
TextBox39.text = Sheets("Database").Cells(y, 1)
TextBox2.text = Sheets("Database").Cells(y, 5)
TextBox3.text = Sheets("Database").Cells(y, 12)
TextBox4.text = Sheets("Database").Cells(y, 13)
TextBox5.text = Sheets("Database").Cells(y, 7)
TextBox7.text = Sheets("Database").Cells(y, 8)
TextBox8.text = Sheets("Database").Cells(y, 20)
TextBox9.text = Sheets("Database").Cells(y, 4)
TextBox10.text = Sheets("Database").Cells(y, 2)
TextBox12.text = Sheets("Database").Cells(y, 3)
TextBox13.text = Sheets("Database").Cells(y, 18)
TextBox14.text = Sheets("Database").Cells(y, 21)
TextBox15.text = Sheets("Database").Cells(y, 9)
TextBox17.text = Sheets("Database").Cells(y, 22)
TextBox18.text = Sheets("Database").Cells(y, 23)
TextBox19.text = Sheets("Database").Cells(y, 25)
TextBox20.text = Sheets("Database").Cells(y, 26)
TextBox21.text = Sheets("Database").Cells(y, 28)
TextBox22.text = Sheets("Database").Cells(y, 29)
TextBox23.text = Sheets("Database").Cells(y, 30)
TextBox24.text = Sheets("Database").Cells(y, 33)
TextBox25.text = Sheets("Database").Cells(y, 32)
TextBox26.text = Sheets("Database").Cells(y, 31)
TextBox27.text = Sheets("Database").Cells(y, 35)
TextBox28.text = Sheets("Database").Cells(y, 37)
TextBox29.text = Sheets("Database").Cells(y, 39)
TextBox32.text = Sheets("Database").Cells(y, 40)
TextBox33.text = Sheets("Database").Cells(y, 41)
TextBox34.text = Sheets("Database").Cells(y, 42)
TextBox35.text = Sheets("Database").Cells(y, 45)
TextBox36.text = Sheets("Database").Cells(y, 50)
TextBox37.text = Sheets("Database").Cells(y, 17)
TextBox38.text = Sheets("Database").Cells(y, 19)
TextBox39.text = Sheets("Database").Cells(y, 1)
TextBox40.text = Sheets("Database").Cells(y, 15)
ComboBox1.text = Sheets("Database").Cells(y, 6)
ComboBox2.text = Sheets("Database").Cells(y, 16)
ComboBox3.text = Sheets("Database").Cells(y, 10)
ComboBox4.text = Sheets("Database").Cells(y, 11)
ComboBox5.text = Sheets("Database").Cells(y, 14)
ComboBox7.text = Sheets("Database").Cells(y, 24)
ComboBox8.text = Sheets("Database").Cells(y, 27)
ComboBox9.text = Sheets("Database").Cells(y, 34)
ComboBox11.text = Sheets("Database").Cells(y, 38)
ComboBox12.text = Sheets("Database").Cells(y, 36)
ComboBox13.text = Sheets("Database").Cells(y, 43)
ComboBox14.text = Sheets("Database").Cells(y, 44)
ComboBox15.text = Sheets("Database").Cells(y, 46)
ComboBox16.text = Sheets("Database").Cells(y, 47)
ComboBox17.text = Sheets("Database").Cells(y, 48)
ComboBox18.text = Sheets("Database").Cells(y, 49)
ComboBox19.text = Sheets("Database").Cells(y, 51)
ComboBox20.text = Sheets("Database").Cells(y, 52)
'=================================================
'start code for Search Student Image and Display
'=================================================
On Error Resume Next
Image1.Picture = LoadPicture("C:\Photo\" & TextBox10.text & Value & ".jpg")
Image1.PictureSizeMode = 1
End If
Next y
End Sub
Private Sub CommandButton9_Click()
'===============================================================
'start code for Update Student Information IN Database Worksheet
'================================================================
On Error Resume Next
Dim x As Long
Dim y As Long
x = Sheets("Database").Range("A" & Rows.Count).End(xlUp).Row
For y = 2 To x
If Sheets("Database").Cells(y, 1).text = TextBox41.Value Then
Sheets("Database").Cells(y, 5) = TextBox2.text
Sheets("Database").Cells(y, 12) = TextBox3.text
Sheets("Database").Cells(y, 13) = TextBox4.text
Sheets("Database").Cells(y, 7) = TextBox5.text
Sheets("Database").Cells(y, 8) = TextBox7.text
Sheets("Database").Cells(y, 20) = TextBox8.text
Sheets("Database").Cells(y, 4) = TextBox9.text
Sheets("Database").Cells(y, 2) = TextBox10.text
Sheets("Database").Cells(y, 3) = TextBox12.text
Sheets("Database").Cells(y, 18) = TextBox13.text
Sheets("Database").Cells(y, 21) = TextBox14.text
Sheets("Database").Cells(y, 9) = TextBox15.text
Sheets("Database").Cells(y, 22) = TextBox17.text
Sheets("Database").Cells(y, 23) = TextBox18.text
Sheets("Database").Cells(y, 25) = TextBox19.text
Sheets("Database").Cells(y, 26) = TextBox20.text
Sheets("Database").Cells(y, 28) = TextBox21.text
Sheets("Database").Cells(y, 29) = TextBox22.text
Sheets("Database").Cells(y, 30) = TextBox23.text
Sheets("Database").Cells(y, 33) = TextBox24.text
Sheets("Database").Cells(y, 32) = TextBox25.text
Sheets("Database").Cells(y, 31) = TextBox26.text
Sheets("Database").Cells(y, 35) = TextBox27.text
Sheets("Database").Cells(y, 37) = TextBox28.text
Sheets("Database").Cells(y, 39) = TextBox29.text
Sheets("Database").Cells(y, 40) = TextBox32.text
Sheets("Database").Cells(y, 41) = TextBox33.text
Sheets("Database").Cells(y, 42) = TextBox34.text
Sheets("Database").Cells(y, 45) = TextBox35.text
Sheets("Database").Cells(y, 50) = TextBox36.text
Sheets("Database").Cells(y, 17) = TextBox37.text
Sheets("Database").Cells(y, 19) = TextBox38.text
Sheets("Database").Cells(y, 1) = TextBox39.text
Sheets("Database").Cells(y, 15) = TextBox40.text
Sheets("Database").Cells(y, 6) = ComboBox1.text
Sheets("Database").Cells(y, 16) = ComboBox2.text
Sheets("Database").Cells(y, 10) = ComboBox3.text
Sheets("Database").Cells(y, 11) = ComboBox4.text
Sheets("Database").Cells(y, 14) = ComboBox5.text
Sheets("Database").Cells(y, 24) = ComboBox7.text
Sheets("Database").Cells(y, 27) = ComboBox8.text
Sheets("Database").Cells(y, 34) = ComboBox9.text
Sheets("Database").Cells(y, 38) = ComboBox11.text
Sheets("Database").Cells(y, 36) = ComboBox12.text
Sheets("Database").Cells(y, 43) = ComboBox13.text
Sheets("Database").Cells(y, 44) = ComboBox14.text
Sheets("Database").Cells(y, 46) = ComboBox15.text
Sheets("Database").Cells(y, 47) = ComboBox16.text
Sheets("Database").Cells(y, 48) = ComboBox17.text
Sheets("Database").Cells(y, 49) = ComboBox18.text
Sheets("Database").Cells(y, 51) = ComboBox19.text
Sheets("Database").Cells(y, 52) = ComboBox20.text
'=====================================
'start code for Update Student photo
'=====================================
On Error Resume Next
Dim i As String
i = TextBox1.text
FileCopy fpath, "C:\Photo\" & i & ".jpg"
Me.TextBox2.text = ""
End If
Next y
MsgBox "Student Information updated successfully.", vbOKOnly, "Learn with MSexcelvba.Com"
Unload Me
Admission.Show
End Sub
Private Sub TextBox1_Change()
End Sub
Private Sub Frame6_Click()
End Sub
'=====================================================================================================================
'Start code for Enter Numbers only in TextBox (Copy the source code from https://www.MSexcelvba.com) and use for TextBox.
'=====================================================================================================================
Private Sub TextBox13_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
'========================================================
'start code for write Numbers only in TextBox6
'========================================================
On Error Resume Next
If (KeyAscii > 47 And KeyAscii < 58) Then
KeyAscii = KeyAscii
Else
KeyAscii = 0
MsgBox "Invalid Key Pressed, You Can Enter Numbers Only", vbOKOnly, "Learn with MSexcelvba.Com"
End If
End Sub
Private Sub TextBox37_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
'========================================================
'start code for write Numbers only in TextBox6
'========================================================
On Error Resume Next
If (KeyAscii > 47 And KeyAscii < 58) Then
KeyAscii = KeyAscii
Else
KeyAscii = 0
MsgBox "Invalid Key Pressed, You Can Enter Numbers Only", vbOKOnly, "Learn with MSexcelvba.Com"
End If
End Sub
Private Sub TextBox38_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
'========================================================
'start code for write Numbers only in TextBox6
'========================================================
On Error Resume Next
If (KeyAscii > 47 And KeyAscii < 58) Then
KeyAscii = KeyAscii
Else
KeyAscii = 0
MsgBox "Invalid Key Pressed, You Can Enter Numbers Only", vbOKOnly, "Learn with MSexcelvba.Com"
End If
End Sub
'========================================================
'End code for write Numbers only in TextBox
'========================================================
'=====================================================================================================================
'start code for write Proper Text in TextBox (Copy the source code from https://www.MSexcelvba.com) and use for TextBox.
'=====================================================================================================================
'=============================
'Proper Sentence for TextBox3
'=============================
Private Sub TextBox3_Change()
Me.TextBox3 = Application.WorksheetFunction.Proper(TextBox3)
End Sub
'=============================
'Proper Sentence for TextBox4
'=============================
Private Sub TextBox4_Change()
Me.TextBox4 = Application.WorksheetFunction.Proper(TextBox4)
End Sub
'=============================
'Proper Sentence for TextBox15
'=============================
Private Sub TextBox15_Change()
Me.TextBox15 = Application.WorksheetFunction.Proper(TextBox15)
End Sub
'=============================
'Proper Sentence for TextBox8
'=============================
Private Sub TextBox8_Change()
Me.TextBox8 = Application.WorksheetFunction.Proper(TextBox8)
End Sub
'=============================
'Proper Sentence for TextBox14
'=============================
Private Sub TextBox14_Change()
Me.TextBox14 = Application.WorksheetFunction.Proper(TextBox14)
End Sub
'=============================
'Proper Sentence for TextBox19
'=============================
Private Sub TextBox19_Change()
Me.TextBox19 = Application.WorksheetFunction.Proper(TextBox19)
End Sub
'=============================
'Proper Sentence for TextBox21
'=============================
Private Sub TextBox21_Change()
Me.TextBox21 = Application.WorksheetFunction.Proper(TextBox21)
End Sub
'=============================
'Proper Sentence for TextBox26
'=============================
Private Sub TextBox26_Change()
Me.TextBox26 = Application.WorksheetFunction.Proper(TextBox26)
End Sub
'=============================
'Proper Sentence for TextBox27
'=============================
Private Sub TextBox27_Change()
Me.TextBox27 = Application.WorksheetFunction.Proper(TextBox27)
End Sub
'=============================
'Proper Sentence for TextBox28
'=============================
Private Sub TextBox28_Change()
Me.TextBox28 = Application.WorksheetFunction.Proper(TextBox28)
End Sub
'=============================
'Proper Sentence for TextBox29
'=============================
Private Sub TextBox29_Change()
Me.TextBox29 = Application.WorksheetFunction.Proper(TextBox29)
End Sub
'=============================
'Proper Sentence for TextBox36
'=============================
Private Sub TextBox36_Change()
Me.TextBox36 = Application.WorksheetFunction.Proper(TextBox36)
End Sub
'=============================
'Proper Sentence for TextBox23
'=============================
Private Sub TextBox23_Change()
Me.TextBox23 = Application.WorksheetFunction.Proper(TextBox23)
End Sub
'=============================
'Proper Sentence for TextBox24
'=============================
Private Sub TextBox24_Change()
Me.TextBox24 = Application.WorksheetFunction.Proper(TextBox24)
End Sub
'=============================
'Proper Sentence for TextBox34
'=============================
Private Sub TextBox34_Change()
Me.TextBox34 = Application.WorksheetFunction.Proper(TextBox34)
End Sub
Private Sub UserForm_Initialize()
On Error Resume Next
'==============================================================================
'Start code for show autometic current Date in Admission Date
'==============================================================================
TextBox9.text = Date
End Sub