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

Is There a Way to Turn On and Off Visiablity?? 1

Status
Not open for further replies.

quest4

Technical User
Aug 27, 2001
735
US
I have a form, with six pages and six controll buttoms to send me to each page. In the form I have a field, PayType, in which we have two choices, if the selection is "per Week", that meaans the employee is salaried. If he is I would like not to see the sub-form on page 5 and I would like to not see the "6" controll button. The salaried employees are mixed in with the hourly eemployees, which I do want to see the page 6 subform and the "6" contoll button. Thanks to anyone who lends a helping hand on this one.
 
I'm assuming when you say pages that you mean tabs???? Does this form allow you to scroll through each employee? Or do you have to type in an employee and press a button? I can't tell you what events to use because I'm confused about how your form is laid out, however I can provide you with sample code to turn things on and off. Here it is:

[tt]
If PayType = "Per Week" Then
MyPage5.Visible = False
MyControl6.Visible = False
Else
MyPage5.Visible = True
MyControl6.Visible = True
End If
[/tt]

I don't know what the names of your controls, buttons, pages are but that's the basic way the code will go.

HTH Joe Miller
joe.miller@flotech.net
 
Joe thanks for your response. My form a continuous form with six page breaks, hence pages, I use a command button for each page, which run a macro set to GoToPage. I allows me to go to each page much like the tabs but it looks alot better. Each command button is simply the page number, 1-6. I have another command button called "NEXT" which is GoToNextRecord to move through the employees records. I am just trying to eliminate the attendence subform for salaried employees, which are not even listed on the form and the command button that goes with it. Maybe this will help simplify what I am trying to do. Again thanks for the help, I will start to play with it.
 
Oh I forgot to mention that the command button is "Command Button 125" and the subform is "sfrmqrytblAttendence".
 
OK, I give up. Where do you put this statement to get it to work? I have tried everywhere in form properties to individual field properties, nothing works. What I'm I missing.
 
I tried to put this code in form properties events under OnCurrent and set it to Event Procedure. This is the modification that I thought I would need:

Private Sub Form_Current()
If tblEmployees.Paytype="per Week" Then
Me!CommandButton125.Visable=False
Me!sfrmqryAttendence.Visable=False
Else
Me!CommandButton125.Visable=True
Me!sfrmqryAttendence.Visable=True
End If
End Sub

When I open the form, any button I click I get a error message saying that this is amiguious and won't be able to find or run my macro. Any suggestions? Did I put it in the right place? Is my syntax correct? Thanks for any help coming.
 
I got it to run without any errors finally. It does not do anything at all. Here is my working code:
Private Sub Current()
If Paytype="per Week" Then
CommandButton125.Visable=False
sfrmqryAttendence.Visable=False
Else
CommandButton125.Visable=True
sfrmqryAttendence.Visable=True
End If
End Sub

Any idaes, please help. Thanks.
 
You have spelled VISIBLE incorrectly:

If Paytype="per Week" Then
CommandButton125.Visible=False
sfrmqryAttendence.Visible=False
Else
CommandButton125.Visible=True
sfrmqryAttendence.Visible=True
End If Joe Miller
joe.miller@flotech.net
 
You are correct, but it still does not work. Both the sub form and the command button are visible for everyone including the salaried employees. Thanks for the response, I really appreachiate it.

PS Is OnCurrent the right place to put this procedure?
 
In fustration, I made a few changes, I changed the "FAalse" to "No" and I channged the "True" to "Yes". I also changed Current() to Form_Current(). Noe I get a runtime error 424 when I try to enter the form and every time I click the next command button. Also now on all employees the subform is invisible and so is the command button. Any suggestion on this one?
 
OK, the run time error is being caused by the sub-form for some unknown reason. However, the command button is always invisible, again, for some unknown reason. Any suggestions? Thanks.
 
I got the command buton working correctly with a few minor changes. I rename command125 to Page6, to make more sense, and here is the result:

Private Sub Form_Current()
If PayType = "per Week" Then
Page6.Visible = False
sfrmqryAttendence.Visible = False
ElseIf PayType = "per Hour" Then
Page6.Visible = True
sfrmqryAttendence.Visible = True
End If
End Sub

The only problem is that when I open the form and everytime I click on the next command button I get a Run Time error:424, and the debugger goes to one of the sub-form lines, but it will become invisible when it should. Why is the sub_form giving me this error? Any suggestions on how to correct it? Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top