Hi,
TBL_CONTACT_PERSON
CNTP_ID (auto)
CNTP_LAST_NAME (required = yes)
CNTP_FUNCTION (required = no)
CNTP_..... (all required = no)
FRM_CONTACT_PERSON_ADD_NEW
Property DATA ENTRY = YES
No closebutton ( user leaves pressing 'Add' or 'Exit no adding'
CmdAdd
CmdExitNoAdd
Problem with Private Sub CmdAdd_Click() > see code below *********
If the user presses 'add' i want to test if Me.CNTP_LAST_NAME has data. If
not > MsgBox "Unable to add person without LastName!" and stay in the form.
1. if i do not enter any value in any field the test
IsNull(Me.CNTP_LAST_NAME) returns True
but MsgBox Me.CNTP_LAST_NAME triggers error 'invalid use of null" ???
2. if i only enter the CNTP_FUNCTION leaving Me.CNTP_LAST_NAME blanc, the
test IsNull(Me.CNTP_LAST_NAME) returns False
Please help,
Filip
************************************************** **************************
**********
Private Sub CmdAdd_Click()
On Error GoTo ErrHandling
If IsNull(Me.CNTP_LAST_NAME) Then
MsgBox Me.CNTP_LAST_NAME 'this msgbox is just for testing
MsgBox "Unable to add person, need LastName!"
Exit Sub
Else
DoCmd.Close acForm, Me.Name, acSaveYes
End If
Exit Sub
ErrHandling:
MsgBox Err.Number & " " & Err.Description
End Sub
************************************************** **