Results 1 to 2 of 2
  1. #1
    Zerdan is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    May 2011
    Posts
    15

    Searching asking for Parameters

    I have a Form that I'm entering search parameters on and then clicking search. My logic for the "search" button is checking if each field is null and if it is not appending those parameters to a query string.



    Then one the query string is complete I'm using DoCmd.OpenForm to open a new form that displays the filtered results.

    So far I have gotten text fields with dates and checkboxes to work from the search parameters page. I'm now trying to add a textfield to the parameters page and I'm running into trouble. When I enter something in and hit search it pops up "Enter Parameter Value" and then below that says whatever was entered into the textfield. If I then re-enter my search criteria the search works properly. How do I avoid this "Enter Parameter Value" step?

    Code:
    If Not IsNull(Me.txtIncidentNumber) Then
         strQuery = strIncidentNumber & " = " & Me.txtIncidentNumber
    End If
    In the above code the strIncidentNumber is my Column in the database that I'm trying to match.

    Thanks for any help.

  2. #2
    Zerdan is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    May 2011
    Posts
    15
    I waited so long to post and then figured it out almost immediately after I do. Sorry!

    Code:
    If Not IsNull(Me.txtIncidentNumber) Then
         strQuery = strIncidentNumber & " = " & Me.txtIncidentNumber
    End If
    I had an error in my SQL syntax. I was doing Row = String instead of Row = 'String'

    I changed my code to


    Code:
    If Not IsNull(Me.txtIncidentNumber) Then
         strQuery = strIncidentNumber & " = " & "'" & Me.txtIncidentNumber & "'"
    End If
    And that solved the issue.

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

Similar Threads

  1. Searching Question
    By Jbelle7435 in forum Programming
    Replies: 5
    Last Post: 05-15-2011, 07:48 AM
  2. Searching in the form
    By seeter in forum Forms
    Replies: 11
    Last Post: 08-10-2010, 08:37 AM
  3. Advanced Searching
    By mbolster in forum Forms
    Replies: 3
    Last Post: 07-06-2010, 10:10 AM
  4. Searching the database
    By rommelgenlight in forum Access
    Replies: 0
    Last Post: 03-29-2009, 10:38 PM
  5. Help with Searching Dates
    By rededdie in forum Access
    Replies: 1
    Last Post: 11-02-2007, 08:34 AM

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