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!

Disable subforms until record is entered

Status
Not open for further replies.

Chad1984

Technical User
Jul 10, 2007
35
US
Hi all. I'm making a database for a client who wants the subforms to be disabled until the main form has a complete record entered. Of course, the database relationships will ensure that no record could be entered in a subform until a record is entered on the "one" side of the relationship, but the client wants it to prevent people from even trying to enter a record.

I could write code that would disable all the controls in the form's current method if any of the required fields are null. But that doesn't allow for any other validation criteria those fields have, AND it doesn't enable the subforms right away; the user has to switch records and switch back or otherwise fire the current method.

Is there a better way to write code that will allow the user to just tab through the fields, entering data and tabbing right into the subform- but that will keep the subforms disabled if they didn't fully enter a complete record?
 
Set the property of your subform to Enabled - NO

Then use the OnCurrent Event of your main form to put your criteria and change the Subform to Enabled = YES once the criteria has been filled.

Hope that helps
 
How are ya Chad1984 . . .

Let the mainforms [blue]Before Update[/blue] event be your [blue]gestapo![/blue] If any field fails validation you set focus to that field and set the [blue]Cancel[/blue] arguement to false. This way user can't goto subform unless the edited record on the mainform ([blue]new record or not[/blue]) validates!

[blue]Your thoughts? . . .[/blue]

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

Be sure to see FAQ219-2884:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top