I am puttig the actual code....Please do help me out Gemma.
Private Sub cmdadd_Click()
On Error GoTo Error_Handle
Dim todaydate
todaydate = Now()
'setuser is a function already defined in another module.This works correct
Dim updater As String
updater = setuser()
'validations
If IsNull(Me.txtid) Or IsDate(Me.txtid) Then
MsgBox "Centre field can't be null or with date."
Exit Sub
ElseIf IsNumeric(Me.txtname) Or IsDate(Me.txtname) Or IsNull(Me.txtname) Then
MsgBox "Centre name field can't be null,numeric or a date field."
Exit Sub
ElseIf IsNumeric(Me.txtdname) Or IsDate(Me.txtdname) Or IsNull(Me.txtdname) Then
MsgBox "Director name field can't be null,numeric or a date field.", vbInformation, "Validation Error"
Exit Sub
ElseIf IsNumeric(Me.txtdhname) Or IsDate(Me.txtdhname) Or IsNull(Me.txtdhname) Then
MsgBox "Department Head name field can't be null,numeric or a date field.", vbInformation, "Validation Error"
Exit Sub
ElseIf IsNumeric(Me.txtmname) Or IsDate(Me.txtmname) Or IsNull(Me.txtmname) Then
MsgBox "Manager name field can't be null,numeric or a date field.", vbInformation, "Validation Error"
Exit Sub
End If
Me.Dirty = False
DoCmd.SetWarnings False
STATEMENT = "INSERT INTO Centre (Centre,Centre_Name,Director,Department_Head,Manager,Last_Updated_By,Last_Updated_Date) VALUES ('" & Me.txtid & "', '" & Me.txtname & "','" & Me.txtdname & "','" & Me.txtdhname & "','" & Me.txtmname & "','" & updater & "','" & todaydate & "')"
DoCmd.RunSQL STATEMENT
MsgBox "Record saved successfully", vbOKOnly, "NT SLA Tool"
Exit sub
Error_Handle:
MsgBox "There's another Center with the same number"
End Sub