Controlling visability of a command button

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi.

How can I arrange for a command button, cmdCommandB, on frmFormB to be made
invisable when frmFormB is opened by command buttom cmdCommandA on frmFormA.
Is there code I can put in the On Click event of cmdCommandA, in addition to
the code already there to open frmFormB, that achieves this?

Thanks, JohnB
 
Hi.

How can I arrange for a command button, cmdCommandB, on frmFormB to be made
invisable when frmFormB is opened by command buttom cmdCommandA on frmFormA.
Is there code I can put in the On Click event of cmdCommandA, in addition to
the code already there to open frmFormB, that achieves this?

Thanks, JohnB

On FormA code the cmdCommandB click event:

DoCmd.OpenForm "FormB", , , , , , "NotVisible"

On FormB, code the Load event:

If Not isNull(Me.OpenArgs) Then
If Me.OpenArgs = "NotVisible" Then
cmdCommandB.Visible = False
End If
End If
 
Thanks for this. I've now tried it using my actual form and command button
names and, although it compiles OK and does not cause any error messages, the
appropriate button is remaining visable. Here is my code;

On the first command buttons On Click event:

DoCmd.OpenForm "frmSECMentors", , , "MentorID IN (SELECT MentorID FROM
qrySECAllMentors WHERE (qrySECAllMentors.School=" & SchoolID & " And
[MovedToSchoolID] Is Null))", , , "NotVisable"

In the On Load event of form frmSECMentors:

Private Sub Form_Load()
If Not IsNull(Me.OpenArgs) Then
If Me.OpenArgs = "NotVisible" Then
cmdViewSchoolRecord.Visible = False
End If
End If

End Sub

If I change the above to True,or if I change "If Not IsNull(Me.OpenArgs)
Then" to "If IsNull(Me.OpenArgs) Then", same result i.e. cmdViewSchoolRecord
remains visable and no error messages.

Any idea what I'm doing wrong? Thanks, JohnB
 
O.K O.K so I can't spell! Sorry about that. Works perfectly when I use
Visible in the calling code. Many thanks for the help. JohnB
 
O.K O.K so I can't spell! Sorry about that. Works perfectly when I use
Visible in the calling code. Many thanks for the help. JohnB

I see.
We see what we expect to see, not what we see.
Si? :-)
 
Back
Top