Results 1 to 5 of 5
  1. #1
    The Phil is offline Novice
    Windows XP Access 2003
    Join Date
    Apr 2010
    Posts
    2

    Report query by digits


    Hi, I'm kind of new to access but I understand computers well so I think I'll pick it up quick.

    I'm trying to make a report based on the account numbers in the database. It will be an income statement. All of the values in the account column are 6 digits long. I want it to look at the 3rd and 4th digits and if they are 31 then it goes on the Income line in the report and if the 3rd and 4th digits are 41 then it goes in the expense line in the report. The income and expense lines in the report will be a gross total of all of the rows that meet the criteria.

    My end result will be much more complicated than this but once I understand the concept I should be able to do the rest myself.

    Thanks!

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    You will want to look at the Mid() function.

  3. #3
    maximus's Avatar
    maximus is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    The main problem that you have is extracting the third and the fourth number from your six digit number.

    This expression will help you. Text Here will be you Account Number Field
    Number: Right(Left([Text],4),2)

    You can even use it in a query as a calculative field and enhance the code Like this:

    Number: IIf(Right(Left([Text],4),2)=31,"Income",IIf(Right(Left([Text],4),2)=41,"Expenditure"))

    or

    Number1: IIf(Mid([Text],3,2)=31,"Income",IIf(Mid([Text],3,2)=41,"Expenditure"))

    Here the Account Number will be classified either income or expenditure based on the 3rd and the 4th Digit.

    Note: in the second expression I have assumed that the 3rd and the 4th digit either can be 31 or 41.

  4. #4
    The Phil is offline Novice
    Windows XP Access 2003
    Join Date
    Apr 2010
    Posts
    2
    Those formulas make sense to me and I understand what I would need to do to change them to suite my needs. They are similar to excel and I'm quite familiar with excel.

    I guess my biggest problem here is the very basics of setting up the report. I've been googling it but I can't seem to find any articles to help people get started. I understand the code you've posted and what it does but I can't seem to figure out where to apply it to.

    I can upload a small sample file if you like but I think the best thing for me would be to find a well written tutorial online that goes over some of the basics.

    Thanks.

  5. #5
    maximus's Avatar
    maximus is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    I am attaching a sample mdb file go to queries and open the query in the design view and see for yourself. You are most welcome to upload a sample.

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

Similar Threads

  1. Expand entire row not just single cell in a Report
    By CityOfKalamazoo in forum Reports
    Replies: 2
    Last Post: 07-28-2016, 09:22 AM
  2. Adding a 0 to single digit imports
    By TheWolfster in forum Access
    Replies: 6
    Last Post: 02-16-2010, 05:19 PM
  3. Print Single Report
    By emkwan in forum Access
    Replies: 1
    Last Post: 01-29-2010, 11:19 AM
  4. Replies: 0
    Last Post: 11-23-2009, 09:19 PM
  5. Replies: 1
    Last Post: 09-01-2006, 03:49 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