Option Explicit
Public State As FormState
Dim rsr As String 'for reservation string
Dim a As Variant
Sub rload()
Set tbCourse = New ADODB.Recordset
tbCourse.Open "SELECT * FROM tbcourse ", cn, adOpenStatic, adLockReadOnly
End Sub
Private Sub cmbCourse_Click()
a = cmbCourse.Text
Call rload
Do While tbCourse!CourseName <> a
tbCourse.MoveNext
If tbCourse!CourseName = a Then
txtBatch.Text = tbCourse!BatchNumber
End If
Loop
End Sub
Private Sub cmdCancel_Click()
ans = MsgBox("Are you sure you want to cancel this?", vbYesNo + vbQuestion, " Titus School of Multimedia")
If ans = vbYes Then
Unload Me
' tbInquiry.Close
End If
End Sub
Private Sub cmdCheckAvail_Click()
If CheckTextBox(cmbCourse, "Invalid 'COURSE' value. This field is required, please enter a value.") = False Then
ElseIf CheckTextBox(txtBatch, "Invalid 'BATCH NUMBER' value. This field is required, please enter a value.") = False Then
ElseIf frmCheckAvail.txtReser(4).Text = 0 Then
MsgBox "No seat/s available", vbInformation, "Titus School of Multimedia"
Else
frmCheckAvail.Show
End If
End Sub
Private Sub cmdComplete_Click()
If CheckTextBox(cmbCourse, "Invalid 'COURSE' value. This field is required, please enter a value.") = False Then
ElseIf CheckTextBox(txtBatch, "Invalid 'BATCH NUMBER' value. This field is required, please enter a value.") = False Then
ElseIf CheckTextBox(txtNoSeat, "Invalid 'NO. OF SEAT' value. This field is required, please enter a value.") = False Then
ElseIf CheckTextBox(txtAppID, "You cannot move to this part unless you have created New Applicant ID.") = False Then
StartTxt txtAppID
ElseIf CheckTextBox(txtAppInfo(0), "Invalid 'FIRST NAME' value. This field is required, please enter a value.") = False Then
StartTxt txtAppInfo(0)
ElseIf CheckTextBox(txtAppInfo(1), "Invalid 'Middle Name' value. This field is required, please enter a value.") = False Then
StartTxt txtAppInfo(1)
ElseIf CheckTextBox(txtAppInfo(2), "Invalid 'LAST NAME' value. This field is required, please enter a value.") = False Then
StartTxt txtAppInfo(2)
ElseIf CheckTextBox(txtAppInfo(3), "Invalid 'ADDRESS' value. This field is required, please enter a value.") = False Then
StartTxt txtAppInfo(3)
ElseIf CheckTextBox(txtAppInfo(4), "Invalid 'CONTACT NO' value. This field is required, please enter a value.") = False Then
StartTxt txtAppInfo(4)
Else
With tbInquiry
.Open
.MoveFirst
.Find "ApplicantID = '" & txtAppID & "'"
If .EOF = True Then
.AddNew
AddFields
.Update
.Requery
End If
End With
ans = MsgBox("New reservation entry successfully saved to the record." & vbNewLine & "Do You Want To Add Another Record?", vbYesNo, "Titus School Of Multimedia")
If ans = vbNo Then
Unload Me
End If
End If
End Sub
Private Sub cmdSearch_Click()
frmSearch.Show
End Sub
Private Sub Form_Load()
Dim cmb As ListItem
Set tbInquiry = Nothing
tbInquiry.Open "Select * from tbinquiry", cn, adOpenDynamic, adLockOptimistic
tbCourse.Open "Select * from tbCourse", cn, adOpenDynamic, adLockOptimistic
With tbInquiry
frmInquiryForm.txtAppInfo(0).Text = frmAddReservation.txtAppInfo(0).Text
frmInquiryForm.txtAppInfo(1).Text = txtAppInfo(1).Text
frmInquiryForm.txtAppInfo(2).Text = txtAppInfo(2).Text
frmInquiryForm.txtAppInfo(3).Text = txtAppInfo(3).Text
frmInquiryForm.txtAppInfo(4).Text = txtAppInfo(4).Enabled = True
End With
With tbCourse
If .BOF = True And .EOF = True Then
Refresh
Else
Do Until .EOF
cmbCourse.AddItem (.Fields(0))
' cmbBatch.AddItem (.Fields(2))
.MoveNext
Loop
End If
End With
End Sub
Private Sub AddFields()
With tbInquiry
.Fields(0) = txtAppID
.Fields(1) = txtAppInfo(0)
.Fields(2) = txtAppInfo(1)
.Fields(3) = txtAppInfo(2)
.Fields(4) = txtAppInfo(3)
.Fields(5) = txtAppInfo(4)
.Fields(6) = txtTFA
'.Fields(7) = creationdate
.Fields(8) = cmbCourse.Text
.Fields(9) = txtBatch
.Fields(10) = txtNoSeat
.Fields(11) = txtdateReserved
.Fields(12) = txtEndReserved
.Fields(13) = "Reserved"
End With
End Sub
Private Sub EraseAll()
For i = 0 To 4
txtAppInfo(i) = ""
Next i
txtAppInfo(0).SetFocus
For i = 0 To 4
optTFA(i) = ""
Next i
End Sub
Private Sub Form_Unload(Cancel As Integer)
'tbReservation.Close
End Sub
'
'Private Sub txtNoSeat_LostFocus()
'With tbCourse
' .Fields(4) = txtNoSeat.Text - .Fields(1)
'End With
'
'End Sub