Results 1 to 6 of 6
  1. #1
    CraigR is offline Novice
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Posts
    27

    Question Else Question

    I am developing a Database for doing a range of Bushfire/Wildfire calculations, I have written A Grass Fire Danger Index calc which provides a specific number based in certain inputs.
    "GFDI" is the result, however based on the value of the result, will rank the danger level eg Low, Moderate, High, Very High & Extreme.

    The code below is what I am trying for BUT unsure how to achieve it
    Any help would be appreciated, Thank you

    If Me.GFDI_Site01 < "3" Then
    Me.unbound01 = "Low"
    Else
    Me.GFDI_Site01 <> "3" & "7" "This should be if GFDI_Site01 is GREATER 3 but LESS THAN 7 = Moderate


    Me.unbound01 = "Moderate"
    Else
    Me.GFDI_Site01 > "7" And Me.GFDI_Site01 < "20" Then
    "This should be if GFDI_Site01 is GREATER 7 but LESS THAN 20 = High

    Me.unbound01 = "High"
    Else
    Me.GFDI_Site01 > "19" And Me.GFDI_Site01 < "50" Then
    "This should be if GFDI_Site01 is GREATER 19 but LESS THAN 50 = Very High

    Me.unbound01 = "Very High"
    Else
    Me.GFDI_Site01 > "49" Then "This I believe is Correct"
    Me.unbound01 = "Extreme"

    End If

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    you didnt account for =3 , = 7, etc

    Code:
    Select Case Me.GFDI_Site01
    Case Is < 3
      Me.unbound01 = "Low"
    
    Case Is >= 3, Is < 7
         'Me.GFDI_Site01 <> "3" & "7" "This should be if GFDI_Site01 is GREATER 3 but LESS THAN 7 = Moderate
        Me.unbound01 = "Moderate"
    
    Case Is >= 7, Is < 20
        'Me.GFDI_Site01 > "7" And Me.GFDI_Site01 < "20" Then
        '"This should be if GFDI_Site01 is GREATER 7 but LESS THAN 20 = High
        Me.unbound01 = "High"
        
    Case Is > 19, Is < 50
            'Me.GFDI_Site01 > "19" And Me.GFDI_Site01 < "50" Then
            '"This should be if GFDI_Site01 is GREATER 19 but LESS THAN 50 = Very High
        Me.unbound01 = "Very High"
    
    Case Else
        'Me.GFDI_Site01 > "49" Then "This I believe is Correct"
        Me.unbound01 = "Extreme"
    End Select
    End Sub

  3. #3
    CraigR is offline Novice
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Posts
    27
    So it should look like this?

    If Me.GFDI_Site01 < "3" Then
    Me.unbound01 = "Low"
    Else
    Me.GFDI_Site01 >= "3", Is < "7" then
    Me.unbound01 = "Moderate"
    Else
    Me.GFDI_Site01 >= "7", Is < "20" Then
    Me.unbound01 = "High"
    Else
    Me.GFDI_Site01 >= "19", Is < "50" Then
    Me.unbound01 = "Very High"
    Else
    Me.GFDI_Site01 > "49" Then
    Me.unbound01 = "Extreme"
    End If
    End Sub

    each time I insert
    >= I receive a POPUP Box with
    Compile error:

    Expected expression

    ????

  4. #4
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,424
    No, replace your entire IF block with what is shown from Select Case and End Select inclusive.
    Please use code tags for anything much beyond a few lines to make code easier to read. See Ranman256's code section - hope you agree it's easier to read. Plus, forum inserts a space at 50 characters, which can make your code look like it has errors. Is Option Explicit at the top of each of your code modules? If not, suggest you turn on "require variable declaration" or Google this to learn about why.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    CraigR is offline Novice
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Posts
    27
    Thank you
    Did the google search and it is Option Explicit

    Have copied THANK YOU, ranman256
    code into the vb page howevenr nothing


    is populated in unbound01

  6. #6
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,424
    paste your entire procedure here, using code tags. Explain what happens if the control contains a value you expect should be within any of the ranges and let us know what that value is. The problem as I'm seeing it is that if the value is less than 3 or is greater than 49 or is Null, then it's all treated the same because of the Case Else.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 08-25-2012, 07:19 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums