Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!
  1.   Become a Supporter    ::   Make a Contribution   
    Target (Recurring Monthly): $200 :: Achieved: $98

Numeric If...Then...Elseif:...Else...End If statement problem

Discussion in 'Information Technology' started by Jim Ory, Jul 28, 2006.

  1. Jim Ory

    Jim Ory
    Expand Collapse
    Guest

    Good morning,

    Using WinXP and Access2002.

    I should be able to do this; perhaps my brain is on vacation.

    On a form, bound control [intFreq], I enter a number, i.e. 14.070
    Same form, in another bound control [intBand], I need to calculate/determine
    what was in the first control and programmatically enter a value in the
    second control. Both controls are 'number fields', general number format.

    In the Afterupdate event of the first control, I have this:

    If me.intFreq <= 1.8 and >= 2 Then
    me.intBand = 160
    Elseif: me.intFreq <= 3.500 and >= 4 Then
    me.intBand = 80
    Elseif: me.intFreq <=7 and >= 7.3 Then
    me.intBand = 40
    Else:
    End If


    The compile error I get is "Syntax error". I checked the Help in Access and
    did a search on If…Then…Else statements in the discussion group and did not
    find a related topic. I also checked VBA Help, but I was unable to determine
    the meaning of "Block If" well enough to help me.

    --
    Jim Ory
     
  2. Matthias Klaey

    Matthias Klaey
    Expand Collapse
    Guest

    Jim Ory <jim[at]oryfamilyhistory[dot][comma]> wrote:

    >Good morning,
    >
    >Using WinXP and Access2002.
    >
    >I should be able to do this; perhaps my brain is on vacation.
    >
    >On a form, bound control [intFreq], I enter a number, i.e. 14.070
    >Same form, in another bound control [intBand], I need to calculate/determine
    >what was in the first control and programmatically enter a value in the
    >second control. Both controls are 'number fields', general number format.
    >
    >In the Afterupdate event of the first control, I have this:
    >
    >If me.intFreq <= 1.8 and >= 2 Then
    >me.intBand = 160
    >Elseif: me.intFreq <= 3.500 and >= 4 Then
    >me.intBand = 80
    >Elseif: me.intFreq <=7 and >= 7.3 Then
    >me.intBand = 40
    >Else:
    >End If
    >
    >
    >The compile error I get is "Syntax error". I checked the Help in Access and
    >did a search on If…Then…Else statements in the discussion group and did not
    >find a related topic. I also checked VBA Help, but I was unable to determine
    >the meaning of "Block If" well enough to help me.


    The syntax error is in the condition: Instead of

    >If me.intFreq <= 1.8 and >= 2 Then


    you need to write

    If me.intFreq <= 1.8 and me.intFreq >= 2 Then

    BTW this will never be true. Dit you mean

    If me.intFreq >= 1.8 and me.intFreq <= 2 Then

    (both commens apply to the ElseIf conditions too).

    HTH
    Matthias Kläy
    --
    www.kcc.ch
     
  3. Jim Ory

    Jim Ory
    Expand Collapse
    Guest

    Matthias Kläy wrote:

    you need to write

    If me.intFreq <= 1.8 and me.intFreq >= 2 Then

    BTW this will never be true. Dit you mean

    If me.intFreq >= 1.8 and me.intFreq <= 2 Then

    (both commens apply to the ElseIf conditions too).

    Thanks Matthias,

    For the syntax correction and my improper use of 'greater than' and 'less
    than' symbols. I would still be trying to figure that one out.

    --
    Jim Ory
     
Since you're here... we have a small favor to ask...

More people are visiting & reading SPN than ever but far fewer are paying to sustain it. Advertising revenues across the online media have fallen fast. So you can see why we need to ask for your help. Donating to SPN's is vote for free speech, for diversity of opinions, for the right of the people to stand up to religious bigotry. Without any affiliation to any organization, this constant struggle takes a lot of hard work to sustain as we entirely depend on the contributions of our esteemed writers/readers. We do it because we believe our perspective matters – because it might well be your perspective, too... Fund our efforts and together we can keep the world informed about the real Sikh Sikhi Sikhism. If everyone who writes or reads our content, who likes it, helps us to pay for it, our future would be much more secure. Every Contribution Matters, Contribute Generously!

    Become a Supporter      ::     Make a Contribution     



Share This Page