Results 1 to 2 of 2
  1. #1
    SARSSL is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Nov 2012
    Posts
    2

    Angry SQL Statement to Assemble Record Set for Page by Page display

    Greetings:



    Background:
    This is on an FE database, records are from a temporarily generated table that ranks results using AutoNumber field "RANK"; the AutoNumber field resets each time the table data is deleted in the FE by VB code once the desired function is processed. I used the methods and code sampled from a Switchboard to impliment a page by page display of results

    End State:
    User is presented with a Form that displays 10 results at a time, page by page. The caption of the labels on the page is updated to the results of a SQL generated string.

    Issue:
    The SQL string to pull the results is not properly formatted, errors out. However, variables are producing the desired values


    Code with Error:
    stSql = "SELECT * FROM [tbl_mroc_pick]"
    stSql = stSql & " WHERE [RANK] > " & pstart
    stSql = stSql & " AND WHERE [RANK] < " & pend
    stSql = stSql & " ORDER BY [RANK];"
    Set rs = CreateObject("ADODB.Recordset")
    rs.Open stSql, con, 1 ' 1 = adOpenKeyset

    Note:
    variables pstart and pend are being assigned correctly, in the case of page number 1, pstart = 0 and pend = 11
    I simply want the record set to pull records where RANK > 0 and where RANK < 11.

    Suggestions?

  2. #2
    SARSSL is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Nov 2012
    Posts
    2
    Maybe it's just too early in the AM... I saw the correction as soon as I hit post!

    Corrected Code:
    stSql = "SELECT * FROM [tbl_mroc_pick]"
    stSql = stSql & " WHERE [RANK] > " & pstart
    stSql = stSql & " AND [RANK] < " & pend
    stSql = stSql & " ORDER BY [RANK];"
    Set rs = CreateObject("ADODB.Recordset")
    rs.Open stSql, con, 1 ' 1 = adOpenKeyset

    Results:
    Implimentation of Page by Page results displaying 10 records at a time by caption update!

    Kinda cool for only having worked with Access for a week or so... LOL

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

Similar Threads

  1. Replies: 3
    Last Post: 08-07-2011, 09:22 PM
  2. Page break on report inserts empty page between
    By Galadrielle in forum Reports
    Replies: 0
    Last Post: 07-07-2010, 04:18 AM
  3. Replies: 1
    Last Post: 05-22-2010, 08:30 PM
  4. report does not display in 1 page
    By ngeng4 in forum Reports
    Replies: 4
    Last Post: 03-18-2010, 08:26 AM
  5. Replies: 0
    Last Post: 02-11-2009, 06:43 PM

Tags for this Thread

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