how can i automatically add a new number when i click the combo box.
example my inside my combo box i have a course of NURSING, IT, Engineering
then i choose Nursing the txtBatchNUm will automatically generate NUR-0002.
hope anyone can help....
VB Code:
Private Sub cmdSave_Click() With tbCourse .MoveFirst .Find "BatchNumber = '" & txtBatchNum & "'" If .Fields(2) = txtBatchNum Then MsgBox "Batch Number Already Exist.", vbInformation, "Titus School of Multimedia" txtBatchNum = "" txtBatchNum.SetFocus ElseIf .EOF = True Then .AddNew AddFields MsgBox "Batch Number successfully saved to the record.", vbInformation, "Titus School of Multimedia" .Update .Requery txtBatchNum = "" cmbCourse.Clear cmbDepartment.Clear txtNoSeat = "" End If End With End Sub Private Sub Form_Load() With tbCourse If .BOF = True And .EOF = True Then Refresh Else Do Until .EOF cmbCourse.AddItem (.Fields(0)) .MoveNext Loop End If End With With tbDepartment If .BOF = True And .EOF = True Then Refresh Else Do Until .EOF cmbDepartment.AddItem (.Fields(0)) .MoveNext Loop End If End With End Sub Private Sub AddFields() With tbBatch .Fields(0) = cmbCourse .Fields(1) = txtNoSeat .Fields(2) = txtBatchNum .Fields(3) = cmbDepartment End With End Sub




Reply With Quote