Sub form validations

  • Thread starter Thread starter SteveG
  • Start date Start date
S

SteveG

Hi All:
I am pretty new to this stuff, but need to figure out how control data flow
in a form with a bunch of tabbed sub forms. I will try to see if I can make
this make sense:
We have a foirm with a bunch of tabbed sub forms used for dataentry. We need
to control thins so that if someone enters data in a field of one of the sub
forms, they cannot exit the form without clicking the save button and
therefor cannot click on another tab in the master form until the data is
saved. For instance, tab a calls for first name and last name. Once data is
entered into either field, the user cannot click on tab b which would be for
credit limit until the data in tab a has been saved.

Hope this post makes some sense to someone

TIF
 
SteveG -

You can make the other tabs invisible while data is incomplete. If you want
to progress logically from tab 1 to tab 2, etc., then you can start with all
tabs invisible other than tab 1. Then when the user hits the Save button and
data is valid, then you can make tab 2 visible (and hide tab 1 if you want).
Or you can start with all tabs visible, but on any change to a field you can
make the other tabs invisible until the Save button is pressed and data
validated.
 
Thanks Daryl...option 2 would seem to fit better with this project...I kmow
how to make the fields in the sub form invisible, but how would I make them
disappear when a field in one of the sub forms becomes dirty?
 
Steve -

I suspect you would want to make the tabs invisible rather than all the
fields on the tabs or subforms. The code would look something like this
(from the main form):
Me.Page1.Visible = True

You may want to write a form subroutine (in the main form) to manage which
tabs are visible or not. A lot depends on how many conditions would warrant
a change to the viewable tabs, and what logic may be involved. Your function
could accept one parameter that indicates which tab should be visible, and
the code would then set all the other tabs' .visible property to false. Pass
in a specific value to allow all tabs to be visible. Here is a sample, but
use your tab names rather than Page1, Page2, etc.:

Public Sub ShowHideTabs(TabName As String)

Select Case TabName
Case "All"
Me.Page1.Visible = True
Me.Page2.Visible = True
Me.Page3.Visible = True
Case "1"
Me.Page1.Visible = True
Me.Page2.Visible = False
Me.Page3.Visible = False
Case "2"
Me.Page1.Visible = False
Me.Page2.Visible = True
Me.Page3.Visible = False
Case "3"
Me.Page1.Visible = False
Me.Page2.Visible = False
Me.Page3.Visible = True
Case Else
MsgBox "Page " & TabName & " not coded for in ShowHideTabs Subroutine."
Me.Page7.Visible = True
Me.Page8.Visible = True
End Select
End Sub

Then you could simply call this function from any field's On Dirty event.
You could call it from the 'Save Button' to allow all tabs to be visible
after it passed validation. Then if there were any other conditions that
came to light, you would just code a call into this one procedure. The call
to the routine from any tab would be:

ShowHideTabs ("7") 'pass in current page name
 
Back
Top