حياك الله اخي @فايز..
تغيير في حقل الجنس
Private Sub GENRE_AfterUpdate()
If Not IsNull(Me.GENRE) Then
Dim lastID As Integer
Dim lastCode As String
lastID = Nz(DMax("Units_AutoID", "TabUnitsTeachers", "UNITS = '" & Me.GENRE.Value & "'"), 0)
lastCode = Nz(DLookup("CODE", "TabUnitsTeachers", "UNITS = '" & Me.GENRE.Value & "' AND Units_AutoID=" & lastID), vbNullString)
If lastCode = vbNullString Then
lastCode = Switch(Me.GENRE.Value = "ÐßÑ", "01-000", Me.GENRE.Value = "ÃäËì", "02-000")
End If
Me.ID_TEACHER.Value = Left(lastCode, 3) & Format(Val(Right(lastCode, 3)) + 1, "000")
Else
Me.ID_TEACHER.Value = vbNullString
End If
End Sub
وتغيير بعد الحفط
Private Sub Form_AfterUpdate()
If Not IsNull(Me.GENRE) And Not IsNull(Me.ID_TEACHER) Then
DoCmd.RunSQL "INSERT INTO TabUnitsTeachers (UNITS, Code) VALUES ('" & Me.GENRE.Value & "','" & Me.ID_TEACHER.Value & "')"
End If
End Sub