Re: Set The Visibility of A Control Based Off A Combo Box Option

Tech-Archive recommends: Speed Up your PC by fixing your registry



OOOPs!
Sorry. That was a typo. Thanks for the catch, Rob

"Rob Oldfield" wrote:

>
> Lose the me. before the word Private (Klatuu - think you missed your typo)
> and the speech mark after the word Then.
>
>
> "Set The Visibility of A Control"
> <SetTheVisibilityofAControl@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> news:E37B30D5-EEA1-4D8A-804B-5B07AB57B748@xxxxxxxxxxxxxxxx
> > I just keep getting Syntax error Codes. For the first two lines of the
> Code
> >
> > Me.Private Sub Heard_About_Us_AfterUpdate()
> > If Me.Heard_About_Us = "Other" Or Me.Heard_About_Us = "POSTED ELSEWHERE"
> Or
> > Me.Heard_About_Us = "WORD OF MOUTH" Then"
> >
> > "Klatuu" wrote:
> >
> > > Not a problem at all.
> > > So here is how you can debug your code to see what you are actuaill
> getting.
> > > Open your VB Editor so the code you want to test is displayed.
> > > Place the cursor where you want the code to stop. In this case, it will
> be
> > > the first line of executable code. (not tags or dims, but a line of code
> that
> > > does something)
> > > Press F9. You will see that line of code change color.
> > > Open the form in form view and do whatever action is necessary to make
> the
> > > code execute. In this case, make a selection in the combo box.
> > > Your code should then appear. If it does not, select the VB Editor from
> the
> > > task bar.
> > > You should then see the line of code you highlighted earlier is now
> yellow.
> > > It is about to execute this code.
> > > Press F8
> > > The highlighted code will execute and the next line of code to execute
> will
> > > be highlighted in yellow.
> > > At any time the code is stopped, you can position your cursor over a
> > > variable and it will display a box showing the current value. You can
> also
> > > see the value of any object containing data or the setting of a property
> by
> > > referencing it in the immediate window. For example:
> > >
> > > ?forms!MyFormName!Heard_About_Us
> > > will display whatever the current selection is in the combo box.
> > > ?forms!MyFormName!Heard_About_Us.RowSource
> > > will display the the string of the current value of the rowsource
> property.
> > >
> > > Step through your code to be sure it is behaving as you expect.
> > > Check you variable values and property settings to ensure they contain
> the
> > > values you expect.
> > >
> > > "Set The Visibility of A Control" wrote:
> > >
> > > > I cant say as I do ... Like I said Relitively new .. I know this must
> be kind
> > > > of frustrating for you to answer the same questions over and over
> again.
> > > > Thank you so much
> > > >
> > > > "Klatuu" wrote:
> > > >
> > > > > It is not before the sub name. The sub name is Sub
> > > > > Heard_About_Us__AfterUpdate(). It is to qualify the control name.
> Although
> > > > > not always a necessity, it is a good idea that will avoid any
> ambiguity in
> > > > > naming. Me is a shorthand qualifier that references the current
> form.
> > > > > Rather than using:
> > > > > Forms!MyFormName!MyControlName
> > > > > You can use
> > > > > Me.MyControlName
> > > > > Or
> > > > > Me!MyControlName
> > > > >
> > > > > Just plain MyControlName will usually work, but it is better to
> qualify your
> > > > > object references.
> > > > >
> > > > > As to it not working, It looks okay, but you never know. Do you
> know how to
> > > > > trace code in Debug mode?
> > > > >
> > > > > "Set The Visibility of A Control" wrote:
> > > > >
> > > > > > For Some Reason this Code Dosent Seem to Work. What is the Me.
> Thing before
> > > > > > the Sub name ?
> > > > > >
> > > > > > "Klatuu" wrote:
> > > > > >
> > > > > > > Me.Private Sub Heard_About_Us__AfterUpdate()
> > > > > > > If Me.Heard_About_Us = "Other" Or Me.Heard_About_Us = "POSTED
> ELSEWHERE" Or
> > > > > > > Me.Heard_About_Us = "WORD OF MOUTH" Then
> > > > > > > Me.Heard_About_Us_Explain.Visible = True
> > > > > > > Else
> > > > > > > Heard_About_Us_Explain.Visible = False
> > > > > > > End If
> > > > > > > End Sub
> > > > > > >
> > > > > > >
> > > > > > > "Set The Visibility of A Control" wrote:
> > > > > > >
> > > > > > > > Did anyone have a code snippet to make this happen. I have
> tried but I am new
> > > > > > > > to VB and am confused by some of its syntax. My code snippet
> that I have
> > > > > > > > tried Is as follows.
> > > > > > > >
> > > > > > > > Private Sub Heard_About_Us__AfterUpdate()
> > > > > > > > If Heard_About_Us = "Other" Or "POSTED ELSEWHERE" Or "WORD OF
> MOUTH" Then
> > > > > > > > Heard_About_Us_Explain.IsVisible = True
> > > > > > > > Else
> > > > > > > > Heard_About_Us_Explain.IsVisible = False
> > > > > > > > End If
> > > > > > > > End Sub
> > > > > > > >
> > > > > > > > The Combo Box Is Named Heard_About_Us and has 6 options in it.
> > > > > > > > The Control I want to Make Visible Based On the Combo Box
> Criteria is Called
> > > > > > > > Heard_About_Us_Explain .
> > > > > > > >
> > > > > > > > Can U help Me Or anyone Else for that matter ?
>
>
>
.



Relevant Pages