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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Turn On, Turn Off Subform Validation

Status
Not open for further replies.

clearwave

Programmer
Sep 26, 2005
19
US
How do I run this validation code only if the Subform entry is needed?
--------------------
Private Sub DialUpRatePlan_Exit(Cancel As Integer)
If IsNull(Me.DialUpRatePlan) Or Me.DialUpRatePlan = "" Then
MsgBox "Please choose a Dial-Up Rate plan from the drop-down list", vbExclamation, "Required Field"
Cancel = True
End If
End Sub
--------------------
(I'm using this code on every "Required" field on Main & Subform fields)
Currently I have a Main form & multiple Subforms on a Tabbed form. The user enters:
- New records into the Main form (ALWAYS).
- New records into the Subform (SOMETIMES)(or only 1 out of the 3 subforms are needed)

How do I make sure that the Subform validation code DOES NOT run if the user did not need the other 2 subforms?

What's happening now is that when the Main form is closed, Access is prompting for the required subform data from the other 2 subforms, even though the User intentionally passed by them because they were not applicable to this record.

Thanks in advance for your help,
cw
 
How are ya clearwave . . .

Move your code to the [blue]BeforeUpdate[/blue] event of the controls. The [blue]user has to edit a record for the event to fire![/blue]

Calvin.gif
See Ya! . . . . . .
 
Ace, Moving the code from the EXIT to the BeforeUpdate does allow the user to pass by the other subforms & their associated fields, but..

1) Now, It doesn't stop & prompt the User at each field entry.
2) When I had the code in the EXIT event & Focus set to the first field, Access would require that they enter in each field before going to the next one. That is what I have to have.

My only problem has been that - depending on the user's choices on Tab#3, I need the rest of my Subforms (2-6) validation "turned-off"? (see my Tab#3 image below)
OE_Wizard_Choose_Services.gif


Thanks for your help,
cw
 
clearwave . . .

TheAceMan1 said:
[blue]Validation 99.999999% of the time, is checking user data entry, wether the user is adding a new record or editing previously saved . . .

[purple]. . . no data entry . . . no validation required! . . . no need to validate No Change![/purple][/blue]
You said in your [blue]post origination[/blue]:
clearwave said:
[blue](I'm using this code on [purple]every "Required" field on Main & Subform fields[/purple])[/blue]
Then in you latest post:
clearwave said:
[blue]1) Now, It doesn't stop & prompt the User [purple]at each field entry.[/purple][/blue]
[purple]See the ambiguity?[/purple]

There's no guru here who won't tell you, moving to [blue]BeforeUpdate[/blue] for each control won't solve you problem (it was my intent to consolidate this, but now I'm glad I didn't spend the time . . . not trying to be/sound demeaning).

I hope you get my point! . . . your thoughts?

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top