Hide rest of form fields after a certain response

Rachael

Registered User.
Local time
Today, 10:46
Joined
Nov 2, 2000
Messages
205
I have found this piece of code by searching the forum. On putting it in my data base and doing all the right things I get a message when I compile stating that Access wants a procedure not a module and highlights the line of code "Call HideIt("YourFormNameHere")"

Below is a copy of the code etc that i got from the forum, written by Jack Cowley (the wonderful!)


Set the tag property of the fields visibility you want to change to HideIt.
Create a module and add this code:

Function HideIt(FormName As String)
' This procedure will reverse the visability of any
' controls identified with Tag = "HideIt"

Dim F As Form, x As Integer
Set F = Forms(FormName)

For x = 0 To F.Count - 1
If F(x).Tag = "HideIt" Then
F(x).Visible = Not F(x).Visible
End If
Next x

End Function

In the On Current event of the form put code like this:

If Me.YourField = True Or Whatever Then
Call HideIt("YourFormNameHere")
End If

Place the above code in the After Update event of the field that determines if the fields should be visible or not.

Insert the correct name of your form and the correct name of your control that determines if the fields are visible or not.


[This message has been edited by Jack Cowley (edited 12-14-2001).]


Thanks for all responses, I hope I've put in enough information.

Rachael
 
What did you name your module? If it's the same as the function, that may be the problem. If so, rename the module to Module1 or something similar and see if the problem goes away.
 
Rachael -

You are too kind...

The code does work and raskew is probably correct in why the function is not working for you. If you have a probem just let me know...

Wine from Barossa Valley is almost as good as wine from the Napa Valley... JUST KIDDING!

Jack
 
Thanks Guys,

I do have the module called the same name so I reckon that will be the problem.

Cheers, Rachael
 

Users who are viewing this thread

Back
Top Bottom