Re: Hide or show Control Button on Form in Access 97
From: Nikos Yannacopoulos (nyannacoREMOVETHISBIT_at_in.gr)
Date: 07/12/04
- Next message: JulieD: "Re: fill in order"
- Previous message: JohnB: "tab control background"
- In reply to: Pete Sperling: "Re: Hide or show Control Button on Form in Access 97"
- Next in thread: Pete Sperling: "Re: Hide or show Control Button on Form in Access 97"
- Reply: Pete Sperling: "Re: Hide or show Control Button on Form in Access 97"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 12 Jul 2004 14:50:06 +0300
Pete,
To your first question, assuming the subform is called SubForm1, the
references to the command buttons on it should change to:
Me.SubForm1.Formcmdbutton1
etc, so the code would become:
If Me.txtbox1 = "specific text"
Me.SubForm1.cmdbutton1.Visible = True
Else
Me.SubForm1.cmdbutton1.Visible = False
End If
To do the same for multiple buttons, you could either repeat the line of
code after the If / Else keywords, adding one for each button, like:
If Me.txtbox1 = "specific text"
Me.SubForm1.cmdbutton1.Visible = True
Me.SubForm1.cmdbutton2.Visible = True
Me.SubForm1.cmdbutton3.Visible = True
Else
Me.SubForm1.cmdbutton1.Visible = False
Me.SubForm1.cmdbutton2.Visible = False
Me.SubForm1.cmdbutton3.Visible = False
End If
For a big number of buttons you could employ a loop, but it's unlikely it's
your case.
HTH,
Nikos
"Pete Sperling" <PeteSperling@discussions.microsoft.com> wrote in message
news:572D1AD7-C2D2-42E7-9A6B-992F5D686646@microsoft.com...
> Nikos,
> A couple of other questions - The command buttons in question are
contained in the Form Header of a Sub-Form. The control that contains the
specific test is located in the Main Form's Detail area. How is this going
to affect the way the code is written? How do I add addtional "cmdbutton2,
3, 4, etc"? Unfortunately I have no background in writing code. Thanks for
your assistance.
>
> "Nikos Yannacopoulos" wrote:
>
> > Pete,
> >
> > You will need a couple of line of code in the textbox control's Before
> > Update event:
> >
> > If Me.txtbox1 = "specific text"
> > Me.cmdbutton1.Visible = True
> > Else
> > Me.cmdbutton1.Visible = False
> > End If
> >
> > I would suggest you use the same code in the form's On Current event, so
the
> > button is made visible.invisible according to the value of the field in
each
> > record as you browse through... or you could put the code in a private
sub
> > in the form's module, and call it from the two events (so you don't have
to
> > repeat it twice).
> >
> > HTH,
> > Nikos
> >
> > "Pete Sperling" <PeteSperling@discussions.microsoft.com> wrote in
message
> > news:D49496FD-4E93-49E4-BDFD-C15B1A93D8F3@microsoft.com...
> > > I have several control buttons on a form. I would like the control
> > buttons to be hidden unless there is specific text in a control. How
can I
> > make the Visible property of these control buttons be "Yes" depending on
the
> > text in a control on the form and "No" if the text is other than the
desired
> > text. Any assistance greatly appreciated.
> >
> >
> >
- Next message: JulieD: "Re: fill in order"
- Previous message: JohnB: "tab control background"
- In reply to: Pete Sperling: "Re: Hide or show Control Button on Form in Access 97"
- Next in thread: Pete Sperling: "Re: Hide or show Control Button on Form in Access 97"
- Reply: Pete Sperling: "Re: Hide or show Control Button on Form in Access 97"
- Messages sorted by: [ date ] [ thread ]