Redirect with parameter if Recordset has only one record

Posted on 2011-10-24
Last Modified: 2012-05-12
I want to redirect a user if their recordset has only one result.  When they are redirected, I need to pass the url variable.  Otherwise, I will leave them on the results.asp page.  
This is the code I have so far, but it does not work:

If rsCustomerData_total = 1 Then
Response.Redirect("ContactManagementActivityAdd.asp? & var_Table_ID=(rsCustomerData.Fields.Item("Table_ID").Value)")
End If
Question by:drelinger
    LVL 32

    Expert Comment

    by:Big Monty
    have a look at the recordCount property -

    Author Comment

    any hints on syntax to include the required parameter in the url ?
    LVL 32

    Accepted Solution

    when you say URL variable, I assume you want the Table_ID value from the recordset passed?

    rsCustomerData.Open sql, conn

    if rsCustomerData.RecordCount = 1 then
         Response.Redirect( "ContactManagementActivityAdd.asp?&var_Table_ID=" & rsCustomerData.Fields.Item("Table_ID").Value )
    End If

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Suggested Solutions

    Title # Comments Views Activity
    post data with a link 8 45
    How to hide jquery hemiintro in returning user? 1 43
    Select distinct 25 40
    Choose the older file FSO 6 18
    I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
    Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now