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



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

  • Figureing out how long a sub takes to execute
    ... I want to time how long a specific sub takes to execute, ... milliseconds or such to display to a user. ... Prev by Date: ...
    (microsoft.public.dotnet.languages.vb)
  • RE: Create a "cell button" to hide selected cells.
    ... To avoid cluttering up the worksheet with controls, I used a UserForm. ... The user clicks a button on the worksheet to display a UserForm ... Private Sub cmdSetWeeksToShow_Click ...
    (microsoft.public.excel.worksheet.functions)
  • Re: What am I doing wrong?
    ... I do not like a single display, prefering a Flex Grid to display all of the ... Dim rstCompany As Recordset ... Set rstCompany = Nothing ... Private Sub CmdUpdate_Click ...
    (microsoft.public.vb.database.dao)
  • Re: Hardware hackers rejoice!
    ... I've tried to warm up to Perl ... sub getvar { ... # Given 0, the fan is off. ... # Display to LCD ...
    (Ubuntu)
  • Re: filter a combobox
    ... the reason for IsError is that the CB2 linked cell B3 will display ... "Dave Peterson" wrote: ... > Did you put the code behind the worksheet with the comboboxes? ... >> Private Sub ComboBox2_Change ...
    (microsoft.public.excel.programming)

Loading