Results 1 to 8 of 8
  1. #1
    heysus333 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2018
    Posts
    4

    Printing Records Across a Certain Range

    Hi all, I have a database I designed but don't have much experience at all working with Access. I was able to figure most of it out but there is one function I cannot get to work. Currently I have a button for printing out records, each record has the unique ID as its "StrainID". For example if I want to print out a certain strain you just type in the ID of that strain e.g. IU13922 and then press enter.

    However, I want to also be able to print out a report for a certain range of ID's. For example I want all the strains from IU13922-IU13928. I have included my database below as it is setup a bit strangely, as each strain is "paired" with the next sequential number as we store them in duplicates. Since they are paired like this when I enter a range I really want it to print all the even records. If I want the range from IU13922-IU13928, I really just want to print records IU13922, 24, 26, and 28 because each report prints out the even number and the next strain as they are almost identical.

    Hopefully this make some sense, I apologize as I don't have a background in Access at all. If you can offer any advice as how to do this that would be great. Thank you so much in advance!

    DB.zip

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    There are records that don't follow that schema for the StrainID.

    So if the last digit is an even number, retrieve record. Criteria maybe:

    WHERE StrainID BETWEEN [startID] AND [endID] AND Right(StrainID, 1) Mod 2 = 0

    However, the Mod function will error if last character is alpha.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    heysus333 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2018
    Posts
    4
    I see, yes you are correct, there are instances where it isn't an even number. Is it possible to just have the User enter which records to print? Such that they just enter each ID separately and it will generate a report for those ID's?

    The alpha character one is rarely used so it wouldn't be an issue, it just is a hassle to print each one individually and I wanted a way to print across a range and generate a single report instead of numerous individual ones. Thank you for your help!

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Code can be structured to include or exclude the ID's ending in alpha. Which do you prefer?

    Yes, method can be designed to take user input from a combobox and build a comma separated string that can be used as the criteria for OpenReport method, however, there is a limit on how long that string can be.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    heysus333 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2018
    Posts
    4
    Excluding the ID's ending in alpha would be fine, there is only 1 at the moment and it won't ever be printed. Do you know the limit on the string? We typically only do 5-6 ID's at most at any one time or about 40 characters.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Found following in the StrainID field.
    Code:
     IU14674 - this one has a space at the beginning
    E. coli
    IU
    Rosetta
    IU14226=7
    Dh5α
    iu12107
    iu12108
    5 to 6 ID's should be well within the string limit.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    heysus333 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2018
    Posts
    4
    I see okay, there are some that aren't regular but in general the format IUXXXXX is what is typically used. Having the code just follow that would be sufficient.
    Alternatively, I can just have the entries separated by commas but am not sure how to implement that? In the current combo box I have for printing strains what do I need to change to allow for multiple entries separated by commas? And will this allow for a single entry or must it be at least 2 to work? Thanks again for all your help.

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    I do not recommend saving data as comma separated values. Code can take user input and construct comma separated values string for use as filter criteria. Review http://allenbrowne.com/ser-50.html for an example of using a listbox to do that. Allows for single or multiple inputs.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Printing All Records
    By DMT Dave in forum Reports
    Replies: 13
    Last Post: 05-21-2018, 02:05 PM
  2. Replies: 3
    Last Post: 02-10-2016, 01:46 AM
  3. Printing Specific Records
    By spyldbrat in forum Reports
    Replies: 2
    Last Post: 12-28-2015, 01:23 PM
  4. Printing a Range of Invoices (Reports)
    By ManuelLavesa in forum Programming
    Replies: 4
    Last Post: 09-15-2015, 03:16 PM
  5. Continuous Range of Records
    By tigers in forum Access
    Replies: 0
    Last Post: 10-10-2007, 08:36 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