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!

Making a Sub Form unavailable if it does not meet criteria

Status
Not open for further replies.

drslade

IS-IT--Management
May 2, 2003
6
US
I have a form that has multiple sub forms available as tab options. What I want to do is make it so a certain tab (berthing tab) is not available unless the person that the record belongs to lives more than 50 miles from our place of business. Is this possible? Hopefully my question is clearly written. Thanks in advance.

David
 
You could try setting that page to invisible

If (<Your Condition>) = True) then
Me.PageName.Visible = True
Else
Me.PageName.Visible = False
End If

or simply the expression

Me.PageName.Visible = (<Your Condition>)

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 

Well it all depend on how you get to know the 'distance'.

If you have a text box control with the distance in
( or a tick box that says Remote Client Tick here ) etc

Then in the AfterUpdate event for that client put

If txtDistance > 50 Then
( or If tckRemote Then )
TabControlName.Enabled = True
Else
TabControlName.Enabled = False
End If


'ope-that-'elps.




G LS
spsinkNOJUNK@yahoo.co.uk
Remove the NOJUNK to use.
 
David,

As long as you have the distance stored somewhere, it should be pretty straightforward. You'll want to make a funciton that shows or hides the tab page depending on the value of that field. Then you'll call that function from both the OnCurrent event of the main form and the afterUpdate event of the control that holds that distance (if it's stored on this form or another one that can be edited while this form is open).

Here's aircode of one way you might write that function. This one assumes there is a field on the main form that displays the distance. Even if that's the case, you'll have to change things where I guessed at the names of your objects (frmMain, txtDistance,tabWhatever, pgeBerthing):

Function ShowHideBerthing()
If Nz(Forms!frmMain!txtDistance, 0) > 50 Then
Forms!frmMain!tabWhatever.Pages(&quot;pgeBerthing&quot;).Enabled = True
Else
Forms!frmMain!tabWhatever.Pages(&quot;pgeBerthing&quot;).Enabled = False
End If
End Function

You can call it from the two events I mentioned like this

Call ShowHideBerthing

Hope that helps.

Jeremy

==
Jeremy Wallace
AlphaBet City Dataworks
Access Databases for Non-Profit Organizations

Please post in the appropriate forum with a descriptive subject; code and SQL, if referenced; and expected results. See thread181-473997 for more pointers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top