How can i fix the error?
Private Sub cmdadd2_Click()
If cmdadd2.Caption = "ADD" Then
cmdadd2.Caption = "SAVE"
cmdedit2.Caption = "CANCEL"
buttons True, False
a = Date
a = Right(a, 4)
With Adodc2.Recordset
.Filter = "IDnumber like 'F-" + a + "-*'"
If Adodc2.Recordset.RecordCount <> 0 Then
.MoveLast
c = !IDnumber
idn = Right(!IDnumber, 4)
idn = idn + 1
b = Len(idn)
.Filter = "isdeleted = 0"
txtpass2.Text = GenerateCode()
.AddNew
If b = 1 Then
txtid.Text = "F-" + a + "-000" + idn
ElseIf b = 2 Then
txtid.Text = "F-" + a + "-00" + idn
ElseIf b = 3 Then
txtid.Text = "F-" + a + "-0" + idn
ElseIf b = 4 Then
txtid.Text = "F-" + a + "-" + idn
Else
MsgBox "The system reached it's maximum capacity to accomodate new faculty members.", vbCritical, "System"
End If
Else
With Adodc2.Recordset
txtpass2.Text = GenerateCode()
.Filter = "isdeleted = 0"
.AddNew
txtid.Text = "F-" + a + "-0001"
End With
End If
End With
If (txtlname2.Text = "") And (txtfname2.Text = "") Then
MsgBox "Please Fill Out the Required fields"
Else
With Adodc2.Recordset
!IDnumber = txtid.Text
!isdeleted = 0
!lname = txtlname2.Text
!fname = txtfname2.Text
!mname = txtmname2.Text
!gender = txtgender2.Text
!DOBirth = txtmo2.Text & Me.txtd2.Text & Me.txtcity2.Text
!PBirth = txtpobirth2.Text
!degree = txtdeg.Text
!doctorate = txtdoc.Text
!masteral = txtmas.Text
!college = txtcol.Text
!college3 = txtcol3.Text
!college2 = txtcol2.Text
!eadd = txteadd2.Text
!address = txtaddress2.Text
!city = txtcity2.Text
!province = txtstate2.Text
!postalCode = txtpostal2.Text
!cnumber = txtcnumber2.Text
!passcode = txtpass2.Text
.Update
With login.Adodc1.Recordset
.AddNew
!IDNO = Text1.Text
!passcode = txtpass.Text
!isdeleted = 0
!isStudent = 0
!isAdmin = 0
!isTeacher = 1
.Update
End With
.Filter = "isdeleted = 0"
End With
cmdadd2.Caption = "ADD"
cmdedit2.Caption = "EDIT"
buttons False, True
End If
End If
End Sub