locked
Where Clause Range Query RRS feed

  • Question

  • Hi all

    I have  a where clause behind a query form which currently retrieves exact values only based on search criteria.

    What I would like to do is have a user input a value e. g. 1000 and have records returned that are in a range within 10% either side of that value.

    I suspect I need to use the Between function here but am not sure of the syntax.

    The current test is:

    If Not IsNull(txtAreaFt) Then
    If whereclause <> "" Then whereclause = whereclause & " AND "
    whereclause = whereclause & "[TubeArea] = " & txtAreaFt
    End If

    Can anyone help with this code snippet please?

    Thanks

    Phil

    Friday, November 20, 2015 10:59 AM

Answers

  • Try

    whereclause = whereclause & "([TubeArea] Between " & (0.9 * txtAreaFt) & " And " & (1.1 * txtAreaFt) & ")"
    Matthias Kläy, Kläy Computing AG

    • Marked as answer by TheHC Friday, November 20, 2015 3:06 PM
    Friday, November 20, 2015 11:13 AM

All replies

  • Try

    whereclause = whereclause & "([TubeArea] Between " & (0.9 * txtAreaFt) & " And " & (1.1 * txtAreaFt) & ")"
    Matthias Kläy, Kläy Computing AG

    • Marked as answer by TheHC Friday, November 20, 2015 3:06 PM
    Friday, November 20, 2015 11:13 AM
  • Many thanks Matthias - that looks to be spot on.

    Phil

    Friday, November 20, 2015 3:06 PM