Page 1 of 2 12 LastLast
Results 1 to 15 of 22
  1. #1
    AAAndy is offline Advanced Beginner
    Windows 7 64bit Access 2013 32bit
    Join Date
    Aug 2016
    Posts
    68

    Question SQL select to display all records on a continuous report?


    SQL select to display all records on a continuous report?

    Below is what I currently have. It displays the same value in the continuous report instead all values. What do I need to fix?


    Code:
    Dim rs As DAO.Recordset
    Set rs = CurrentDb.OpenRecordset("SELECT * FROM Temporary")
    
    
    If Not (rs.EOF And rs.BOF) Then
        rs.MoveFirst 'Unnecessary in this case, but still a good habit
        Do Until rs.EOF = True
            
            Me.txtAddressee = rs!Addressee
    
    
            rs.MoveNext
        Loop
    Else
        MsgBox "There are no records in the recordset."
    End If
    
    
    MsgBox "Finished looping through records."
    
    
    rs.Close 
    Set rs = Nothing

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,525
    Why not base the report on the table, or the same SQL?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2013
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Set rs = CurrentDb.OpenRecordset("SELECT * FROM Temporary")
    Is "Temporary" a table or a query

    In what event are you using the code shown.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  4. #4
    AAAndy is offline Advanced Beginner
    Windows 7 64bit Access 2013 32bit
    Join Date
    Aug 2016
    Posts
    68
    I am trying to create a report that I can later print. I will have the following fields on the report.

    First Name
    Last Name
    Address 1
    Address 2
    City, State ZipCode

    If there is no Address 2 than I need the below to display, deletes a line Address 2

    First Name
    Last Name
    Address 1
    City, State ZipCode


    Also the City field at time increases and at times decreases.

    I can have a long city name like Winchester-on-the-Severn, Maryland
    or a short one like Chicago, Illinois

    so the city field needs to expand and contract

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,525
    You can handle Address2 with the Can Shrink property of the textbox. You can handle the variable length by concatenating the 3 fields together in a textbox:

    =City & ", " & State & " " & ZipCode
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    AAAndy is offline Advanced Beginner
    Windows 7 64bit Access 2013 32bit
    Join Date
    Aug 2016
    Posts
    68
    Quote Originally Posted by pbaldy View Post
    You can handle Address2 with the Can Shrink property of the textbox. You can handle the variable length by concatenating the 3 fields together in a textbox:

    =City & ", " & State & " " & ZipCode
    In the control source I put in
    =City & ", " & State & " " & ZipCode



    but now it says enter parameter value, city , state, and zip ?

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,525
    Are those your field names?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #8
    AAAndy is offline Advanced Beginner
    Windows 7 64bit Access 2013 32bit
    Join Date
    Aug 2016
    Posts
    68
    Yes, I even tried the below

    = [Temporary]![City] & ", " & [Temporary]![State] & " " & [Temporary]![Zip Code]

    but it does not work

  9. #9
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,525
    What is the record source of the report? It would have to be that table, or SQL that includes those fields. Can you attach the db here?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  10. #10
    AAAndy is offline Advanced Beginner
    Windows 7 64bit Access 2013 32bit
    Join Date
    Aug 2016
    Posts
    68
    Quote Originally Posted by pbaldy View Post
    What is the record source of the report? It would have to be that table, or SQL that includes those fields. Can you attach the db here?
    SELECT Temporary.Addressee, Temporary.Position, Temporary.[Organization Name], Temporary.[Address Line 1], Temporary.[Address Line 2], Temporary.[F Description], Temporary.[C Description] FROM [Temporary];

  11. #11
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,525
    I don't see any of those 3 fields selected.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  12. #12
    AAAndy is offline Advanced Beginner
    Windows 7 64bit Access 2013 32bit
    Join Date
    Aug 2016
    Posts
    68
    Quote Originally Posted by pbaldy View Post
    I don't see any of those 3 fields selected.
    I figured it out, its working now, Thanks for your help!

  13. #13
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,525
    No problem!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  14. #14
    AAAndy is offline Advanced Beginner
    Windows 7 64bit Access 2013 32bit
    Join Date
    Aug 2016
    Posts
    68
    Spaces are being left even when I have Can Grow and Can Shrink options set to YES, What needs to be done?

    I have this

    First Name
    Last Name
    Address 1
    Address 2
    City, State ZipCode

    I want this

    First Name
    Last Name
    Address 1
    City, State ZipCode

    but is is doing this, it leaves spaces

    First Name
    Last Name
    Address 1

    City, State ZipCode

  15. #15
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,525
    Are you sure Address2 is Null? Can you attach the db here?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Select and display multiple records by name
    By confusedbutoptimistic in forum Queries
    Replies: 2
    Last Post: 05-08-2016, 11:00 AM
  2. Replies: 2
    Last Post: 10-04-2015, 02:45 PM
  3. Counting records in report from a select field
    By LaughingBull in forum Access
    Replies: 5
    Last Post: 08-23-2015, 12:09 PM
  4. Display Individual Records in Report
    By Luke in forum Access
    Replies: 2
    Last Post: 07-13-2011, 12:18 PM
  5. Report to display multiple records by date.
    By af01waco in forum Reports
    Replies: 1
    Last Post: 03-21-2009, 02:12 PM

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