Alright....let's back up a couple steps and make sure you learn why. This is much better than me just giving an answer.
In Access, the "Me" is a shortcut to the current object, usually a form or report. When referring to a control on that object, you can use Me.controlname or me!controlname or even Me("controlname"). There are reasons for each one, but I won't delve into that. You refer to a property form or report with Me.property and for controls on the form or report with Me.controlname.property or Me!controlname.property or even Me("controlname").property The square brackets ([]) are only necessary if a portion of the declaration has a space in it...so if you had a control called "first name" you would use Me.[first name] or Me![first name] or Me("first name"). Note the last one, using the paranthesis, does not need the square brackets. This is becuase the double quotes define the name. The square brackets act as a marker for Access to know the full name of something containing spaces.
When using If statements, you need to check one instance for validity.
So if you want to do something if there is a match:
If something = something Then
' Do something
End If
If you want to have an answer or code if the value does not match the condition:
If something = something Then
' Do something
Else
' Do something else
End If
If you need to check for more than one condition, I personally prefer Select statements:
Select Case something
Case something: Do something
Case something else: Do something else
Case another something: Do another something
Case Else: Do this is no match was found in the cases
End Select
I suggest you take a close look at the help files for each of these when you need them until you become comfortable with them.
All that aside, I think the following should work for you:
Code:
Private Sub Report_Open(Cancel As Integer)
' First let's check if the PhyName field is equal to
' _O.R. Materiels Mgr. (Stock)
If Me.PhyName = "_O.R. Materiels Mgr. (Stock)" Then
' Since the PhyName field IS EQUAL to the checked value
' Let's hide the field
Me.PhyName.Visible = False
Else
' Let's make the PhyName field visible, since it is not
' equal to the checked value
Me.PhyName.Visible = True
End If
End Sub
If you have more questions or issues, please let me know.
=======================================
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)
Robert L. Johnson III
CCNA, CCDA, MCSA, CNA, Net+, A+, CHDP
VB/Access Programmer