Validation Rule

tomc

Registered User.
Local time
Today, 15:41
Joined
Jul 27, 2000
Messages
40
I have two tables tblbox with fields BoxID & BoxDesc. The other is tblfile with fields FileID & BoxNo. I have a form frmFormAdd that I use to add files to boxes in tblfile. What would I use in the validation rule property to ensure that when a value is added to the BoxNo field on the add form that box number exists in the BoxID field in tblbox? Is it better to validate at the form level or at the table level? Finally, is there a better way to validate that using the validation rule property?

Thanks, Tom
 
Can you do something like

Private Sub NAME_BeforeUpdate(Cancel As Integer)

If DCount("[Field]", "TableName", "[Field] = [Forms]![FormName]![FormField]") = 0 Then
MsgBox "ID doesn't exist", vbOKOnly, "Attention!"
Cancel = True

End If

End Sub

i think that in your case
Field = BoxID
TableName = tblBox


I think.
Steve
 
Thanks, Steve, That worked like a charm.

Tom
 

Users who are viewing this thread

Back
Top Bottom