Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Design / Validation Question

Status
Not open for further replies.

dotolee

Technical User
Jan 27, 2008
134
CA
I have a master container form that is bound to table1. Then I have a few subforms that are also databound.
My question / problem is this:
On the master form, there are a few fields that need to be defined as "mandatory" but the values cannot be specified until the user has gone through and filled in all the subforms. If I make them mandatory, the system doesn't let me fill out any of the subforms until a value is provided.
How do i get around this?
Any suggestions?
 
How are ya dotolee . . .

Excellent issue. As far as navigation is concerned, [blue]you need a saved record in the mainform before you can edit subforms![/blue] . . . [purple]it doesn't work the other way around![/purple]

Perhaps the [blue]After Update[/blue] event of each subform can call a common routine that sets a flag and determines if requirements are met for those fields . . . and sets focus approriately. The mandatory fields [blue]On Exit[/blue] event checks the flag to determine what to do.

[blue]Your Thoughts? . . .[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
I'd avoid using the built in validation at all.

Create an event that runs OnCurrant and OnClose. This can cehck the various fields - if they fail the validation checks, cancel the event that trggered the check, and return an error to the user.

You could also give the option to the user to return and edit the record, or abandon (delete or undo) the record.

SeeThru
 
What's the difference / advantage between doing it on the OnClose event ... and the After_Update?
Thanks.
 
In each Before_Update on the subforms, i have the following code which works fine:
Private Sub Form_BeforeUpdate(Cancel As Integer)
Call CheckForMissingValues
Call basLogTrans(Me, "RecruitmentID", RecruitmentID)
End Sub

And, when moving between tabs, I prevent the user from skipping a sub form by doing the following:

Private Sub frmInclExclSection2_Enter()
'CollisionDate on section 1
If IsNull(frmInclExclSection1.Controls.Item(6).Value) Then
frmInclExclSection1.SetFocus
End If
End Sub

But I dunno where to put the equivalent logic for the last tab.
I've tried the following on the master form close event:

Private Sub Form_Close()
'Jan 30. Prevent from closing if key fields missing.
If Me.[Enrolled].Value = "" Then
MsgBox ("You must specify whether this participant has been enrolled or not!")
DoCmd.CancelEvent
Exit Sub
Else
'check form3 (form 4 on visual)
If IsNull(frmInclExclSection4.Controls.Item(6).Value) Then
frmInclExclSection4.SetFocus
MsgBox ("Section 4 hasn't been reviewed.")
DoCmd.CancelEvent

End If
End If
But the DOCMD.CANCELEVENT doesn't stop the form from closing. Where do i have to put this code to prevent the user from saving the record without these key fields?
Thanks.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top