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!

Function Running In Reverse & Only Once???

Status
Not open for further replies.

quest4

Technical User
Aug 27, 2001
735
US
I have a Function, when I check a check box, a group/line of text boxes should appear. If the check box is left unchecked, that previously mentioned group of text boxes should be invisible, four in all. Here is the function:
Function ShowHide100()
If Forms!frmqryECNMasterData100.Check140 = Yes Then
Forms!frmqryECNMasterData100.Label132.Visible = True
Forms!frmqryECNMasterData100.Combo133.Visible = True
Forms!frmqryECNMasterData100.Text135.Visible = True
Forms!frmqryECNMasterData100.Text137.Visible = True
Else
Forms!frmqryECNMasterData100.Combo133.Visible = False
Forms!frmqryECNMasterData100.Label132.Visible = False
Forms!frmqryECNMasterData100.Text135.Visible = False
Forms!frmqryECNMasterData100.Text137.Visible = False
End If
End Function
I can not see what is wrong with this function, but when I check the check box now the above boxes become invisible and nothing seems to turn them back on. It is like they are permently invisible, but in the property box it says visible=yes. In the forms property, OnCurrent, I have entered =ShowHide100()and in the checkbox's property, AfterUpDate, I entered =ShowHide100(). Go figure, anyone have an idea on this one? Thank you in advance for any help.
 
If Check140 is the checkbox name in the form "frmqryECNMasterData100", then:

If Forms![frmqryECNMasterData100]![Check140] = Yes Then

or

If Forms![frmqryECNMasterData100]![Check140] = -1 Then



Hope this helps! Anthony J. DeSalvo
President - ScottTech Software
"Integrating Technology with Business"
 
Thank you for the assistance, ajdesalvo. I tried your fix, both way, and reversed it also. Part of the problem is now gone, I can now get the line to appear and disappear, but in REVERSE of what I thought it was going to do. Now, if the check the checkbox the line disappears and if I un check the checkbox the line now appears. Dead opposite of what it is supposed to do. Any more improvements? Thank you very much for the assistance.
 
Did you try:


If Forms![frmqryECNMasterData100]![Check140] = 0 Then
Anthony J. DeSalvo
President - ScottTech Software
"Integrating Technology with Business"
 
Thank you again for the assistance. No I hadn't, but I have now, same results. Reverse. I also tried using the defaults, setting them to Yes and No, again same results, Reverse of what it is suppose to do. Any more ideas? Thank you again for the help, I really appreaciate it.
 
In the debug window, place a break point on the If statement, put your cursor over the Forms![frmqryECNMasterData100]![Check140].

What value is it giving you? Anthony J. DeSalvo
President - ScottTech Software
"Integrating Technology with Business"
 
Thank you again for the assistance. I finally got something, but this is first the I ever worked in the debug window. I first put a break point on the If statement, when I moved the cursor ove the forms, nothing happened. Then in the run menue I used the run user, top of the menu, that high-lighted the if statemment in yellow, then I put a point break on the if statement and move my cursor over the form part and low and be hold it said that it could find the form. That made no sense to me, but I check the forms name in the form property and it was the same as what is in the function. No type-o's, at least this time. I am now officialy confussed. Any other suggestions? Thank you again for all of the help.
 
I am not sure if you have done this exactly, but let's try again.

Put the break point on the if statement. Go back to the form and then check the box. The code will run and staop at the breakpoint, then see what the value is.

If this is what you have done, then there is something we are missing.

Let me know. Anthony J. DeSalvo
President - ScottTech Software
"Integrating Technology with Business"
 
Thank you for the response,ajdesalve. That is what I did, put a point break on the line then i clicked the user run button and moved the cursor on the form name and it said that it could not find the form. Then I checked for type-o's in the function and the property box of the form and the spelling is absolutely the same in all locations. But the form works, but only in reverse of what I thought it was supposed to do. I am going to try to paste this in the event procedure and see if this helps. Thanks you again for the assistance.
 
Below are 2 examples.

1. The following will make visible the controls if Check140 is checked. If it's not checked they will be invisible.
Code:
Function ShowHide100()

    Dim bolVisible as Boolean

    bolVisible = Forms!frmqryECNMasterData100!Check140

    Forms!frmqryECNMasterData100!Label132.Visible = bolVisible 
    Forms!frmqryECNMasterData100!Combo133.Visible = bolVisible 
    Forms!frmqryECNMasterData100!Text135.Visible = bolVisible 
    Forms!frmqryECNMasterData100!Text137.Visible = bolVisible 

End Function


2. The following will make invisible the controls if Check140 is checked. If it's not checked they will be visible.
Code:
Function ShowHide100()

    Dim bolVisible as Boolean

    bolVisible = Not Forms!frmqryECNMasterData100!Check140

    Forms!frmqryECNMasterData100!Label132.Visible = bolVisible 
    Forms!frmqryECNMasterData100!Combo133.Visible = bolVisible 
    Forms!frmqryECNMasterData100!Text135.Visible = bolVisible 
    Forms!frmqryECNMasterData100!Text137.Visible = bolVisible 

End Function
 
Thank you for the response, FancyPrairie. Example one is exactly what I have been trying to acomplish, but with little success, I will try your solution shortly, but I do have one question. Do I still put the =ShowHide100() in the forms OnCurrent property and the checkbox's OnUpDate property? Also, the powers would like the same done to checkbox110, so would I do the same for that checkbox before the end function and add the =ShowHide100() to the chewcbox119's OnUpDate property? Thank you again for all of your time and assistance, if this works I think I go and celebrate.
 
Yes, you need to call the function in the OnCurrent event of the form, and the AfterUpdate events of both check boxes. However, if you want the code to read: If either one of the check boxes is selected, then hide the controls, your code should look like this:
Code:
Function ShowHide100()

    Dim bolVisible as Boolean

    bolVisible = Forms!frmqryECNMasterData100!Check140 or Forms!frmqryECNMasterData100!checkbox110

    Forms!frmqryECNMasterData100!Label132.Visible = bolVisible 
    Forms!frmqryECNMasterData100!Combo133.Visible = bolVisible 
    Forms!frmqryECNMasterData100!Text135.Visible = bolVisible 
    Forms!frmqryECNMasterData100!Text137.Visible = bolVisible 

End Function
 
Thank you again. Actually, it can be either one or both. I chkBox140 is check the group of text boxes will be visible and if the chkbox119 is check that different group of text boxes will be visible. If both are checked, both groups of text boxes will be visible. Thank you again, FanctPrairie, you have been a very big help to me, and I have learned alot from it.
 
Well FancyPrairie, it did not work, yet. I get an error when I open the form, Run time error '94' Invalid use of Null. Any suggestions? Thank you again for all of your assistance.
 
FancyPrairie, well I finely got a chance to work on this. I still get the erro message when I open the form, but this isthe new double combo version:
Function ShowHide100()
Dim bolVisible As Boolean

bolVisible = Forms!frmqryECNMasterData100!Check140

Forms!frmqryECNMasterData100!Label132.Visible = bolVisible
Forms!frmqryECNMasterData100!Combo133.Visible = bolVisible
Forms!frmqryECNMasterData100!Text135.Visible = bolVisible
Forms!frmqryECNMasterData100!Text137.Visible = bolVisible

bolVisible = Forms!frmqryECNMasterData100!Check119

Forms!frmqryECNMasterData100!Label77.Visible = bolVisible
Forms!frmqryECNMasterData100!MfgApprovedBy.Visible = bolVisible
Forms!frmqryECNMasterData100!MfgDate.Visible = bolVisible
Forms!frmqryECNMasterData100!MfgComments.Visible = bolVisible

End Function
I was think and I remember vaguely once I had a problem with null the answer was using Nz. Would that be the answer here? I hope so, cause I am going to bite my tongue and dive in MS help and see if I can come up with anything. Again thank you very much for all of your time and assistance.
 
I'm assuming your check boxes are not defaulted to something, therefore, they are initially null. This should take care of it.
Code:
Function ShowHide100()
    Dim bolVisible As Boolean

    If (Not IsNull(Forms!frmqryECNMasterData100!Check140
)) Then
        bolVisible = Forms!frmqryECNMasterData100!Check140

        Forms!frmqryECNMasterData100!Label132.Visible = bolVisible
        Forms!frmqryECNMasterData100!Combo133.Visible = bolVisible
        Forms!frmqryECNMasterData100!Text135.Visible = bolVisible
        Forms!frmqryECNMasterData100!Text137.Visible = bolVisible
    End If

    If (Not IsNull(Forms!frmqryECNMasterData100!Check119
)) Then

        bolVisible = Forms!frmqryECNMasterData100!Check119

        Forms!frmqryECNMasterData100!Label77.Visible = bolVisible
        Forms!frmqryECNMasterData100!MfgApprovedBy.Visible = bolVisible
        Forms!frmqryECNMasterData100!MfgDate.Visible = bolVisible
        Forms!frmqryECNMasterData100!MfgComments.Visible = bolVisible
    End If
End Function
 
FancyPrairie, so close and let so far away. The two If Not is Null statement both turned red when entered and of course when I opened the form Syntax error did follow. thank you again.
 
FancyPrairie, I think I have been at this to long. My mistake, I works correctly. There is one little flaw, if I uncheck a checked chkbox the group of text boxes that became invisible, won't become visible til another chkbox is checked. Is there something like requery that would get the boxes visible after un-checking a box? Thank you again for everything, I have learned a few things from you also.
 
This line should be in one line, like below

If (Not IsNull(Forms!frmqryECNMasterData100!Check140)) Then

Think ur just cut pasting it to the module and this ends up being on two lines, which is why ur the statements are turning red.

Regards Solomons
 
Thank you Solomons, you are right and I got that fixed. There is one little flaw, if I uncheck a checked chkbox the group of text boxes that became invisible, won't become visible until another chkbox is checked. Is there something like requery that would get the boxes visible after un-checking a box? Thank you again for the help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top