Field Requires Entry

meboz

Registered User.
Local time
Today, 11:49
Joined
Aug 16, 2004
Messages
71
Could anyone point me in the direction of some code that checks the nullness of fields in a form?

Id like it to work in conjunction with the Required property in the table design.

Heres one attempt by myself:

Public Function check_FieldNullity(frmName As Form)
check_FieldNullity = 0
If frmname.NewRecord = true then
Dim ctlMyCtls As Control
For Each ctlMyCtls In frmName.Controls
If InStr(1, ctlMyCtls.Tag, "R", vbDatabaseCompare) = 2 Then
If IsNull(ctlMyCtls) Then
Gmbr = MsgBox("Please make an entry in the field '" & Right(ctlMyCtls.Tag, Len(ctlMyCtls.Tag) - 3) & "'", , "CMS")
ctlMyCtls.SetFocus
check_FieldNullity = 1
Exit Function
End If
End If
Next ctlMyCtls
End If
End Function

The function is called each time id like to check the fields eg On Close

Call check_fieldNullity([forms]![myform])

A side problem also was that i have 2 subforms that im looping through also. If there a no records underlying a subform then the NewRecord condition is always true, which is causing problems cos I dont have to have a record in the subforms for each record on the main forms.

Anyone help me out??
 

Users who are viewing this thread

Back
Top Bottom