472,118 Members | 1,135 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,118 software developers and data experts.

Validating based on data in Parent Form and Subform

Windows MSAccess2003 is not recognizing the subform field that I want to include in my validation.

The Main form has an Account# as PrimaryID and a Start Date & End Date.
The subform has a one-to-many relationship on the Account#, and also has the Detail Budget Data.

I would like to validate a statment that will prohibit updating a budget record if the dates are not filled in (BeforeUpdate):
Macro Condition:
[Start Date] is null AND [Budget Detail] Is Not Null
Macro Action: MsgBox "Need to enter Dates if entering Budget data"
Macro Action: CancelEvent

How can I get Access to recognize the subform field for this type of comparison?

Much obliged for any assistance.
Nov 7 '07 #1
1 3476
14,534 Expert Mod 8TB
The subform object has two events only and enter and exit event. In the enter event you need to put something like the following:

Something like ...

Expand|Select|Wrap|Line Numbers
  1. Private Sub subformObjectName_Enter()
  3.     If IsNull(Me.StartDate) OR IsNull(Me.EndDate) Then
  4.         MsgBox "You must enter a StartDate and EndDate", vbOKOnly
  5.         Me.StartDate.SetFocus
  6.     End If
  8. End Sub
Nov 14 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by Gary Shell | last post: by
1 post views Thread by kenduron | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.