Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Posts
    294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    strwhere problem (Access 2003 )

    I use part of the code linked to a button on a search form. I'm having problems with the first strWhere line. I want it to display the range of numbers between txtsite and txtsite2. When I run this it brings up parameter query boxes asking for the values. Anybody have any idea what I'm doing wrong here? Thanks!!

    If Not IsNull(Me.txtSite) Then
    If Not IsNull(Me.txtSite2) Then
    strWhere = strWhere & " SiteID Between " & Me.txtSite & " And " & Me.txtSite2 & " AND"
    Else
    strWhere = strWhere & " SiteID Like '*" & Me.txtSite & "*' AND"
    End If
    ElseIf Not IsNull(Me.txtSite2) Then
    strWhere = strWhere & " SiteID Like '*" & Me.txtSite2 & "*' AND"
    End If
    If Not IsNull(Me.txtnumber) Then
    strWhere = strWhere & " SiteID Like '*" & Me.txtnumber & "*' AND"
    End If

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: strwhere problem (Access 2003 )

    You're getting dialogs for txtSite and txtSite2 even though you have just checked that they are not null? That sounds odd, but try using

    <code>strWhere = strWhere & " SiteID >= " & Me.txtSite & " And SiteID <= " & Me.txtSite2 & " AND"</code>

    See if that makes a difference.
    Charlotte

  3. #3
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: strwhere problem (Access 2003 )

    Apparently SiteID is a text field, so you need to encapsulate the values of txtSite and txtSite2 in quotation marks, Like this (chr(34) is the " character):

    strWhere = strWhere & " SiteID Between " & chr(34) & Me.txtSite & chr(34) & " And " & chr(34) & Me.txtSite2 & chr(34) & " AND"
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •