Gabriel,
Gabriel,
You have several different problems.
1) You are writing code, but you are NOT placing the code in a code
window. You are attempting to write the code directly on the event
line.
2) The code you are writing, if you placed it in a code window is
incorrectly written.
Read my comments below and then I'll tell you how to access the event
code window.
Sorry, but none of these are working. Not sure if I am doing this right.
Here is my code:
This one doesn't do anything. I have it in the Form Current Event and AfterUpdate of "PM_Report_Req" [checkbox]
=PM_Report_Freq.Visible=[PM_Report_Req]=-1
You are not writing the code correctly.
The line
=PM_Report_Freq.Visible=[PM_Report_Req]=-1
should be written like this:
[PM_Report_Freq].Visible=[PM_Report_Req]=-1
assuming [PM_Report_Req] is the Check Box field.
Notice that there is no = sign in front of [PM_Report_Freq]
And it must be placed in the event code, not on the event line.
If I try
Me!PM_Report_Freq.visible = false in the form Current Event and
= If me.PM_Report_Req = "yes" then
me!PM_Report_Freq.visible = true in the AfterUpdate of "PM_Report_Req" [checkbox]
then I get an error --- "MS Access can't find the macro 'Me!PM_Report_Freq'
This line,
Me!PM_Report_Freq.visible = false
(as code), is written OK.
These next lines (as code) are incorrectly written.
= If me.PM_Report_Req = "yes" then
me!PM_Report_Freq.visible = true
Should read:
If me.PM_Report_Req = Yes then
me!PM_Report_Freq.visible = true
And then you must add code to make it not visible if the check box is
false.
And then you must finish with an End If
Notice that I have used Yes without the quotes.
The value of Yes, in access, is a number value either -1 or 0. A
number must not be surrounded with the quotes.
Here is how to get into the Event code window to write the code.
Display the Form's property sheet.
Click on the Event tab.
On the line that says Current, write
[Event Procedure]
A button with 3 dots will appear.
Click on that button.
The Current event code window will appear.
It will have 2 already existing lines of code.
Between those 2 lines write:
[PM_Report_Freq].Visible=[PM_Report_Req]=-1
Exit the code window by clicking on the upper right hand corner X.
Now click on the Check Box control and click on the Event tab.
Find the After Update event line.
On that line write [Event Procedure].
Follow the previous instructions and enter the same line of code.
Exit the window.
You are done.
Here is how to write the second example you posted. It will work fine
after you correctly enter it in both the Current and AfterUpdate
events. Notice it takes much more code than the one line I suggested.
If me![PM_Report_Req] = yes then
me![PM_Report_Freq].visible = True
Else
me![PM_Report_Freq].visible =False
End If
I hope this gets you started again in the right direction.