Welcome to SPN

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

Sign Up Now!

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
     

Share This Page