Results 1 to 10 of 10
  1. #1
    hokie is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2009
    Posts
    20

    Do i need a custom program for this?

    I have 2 tables [Table1] and [table2]with a unique reference number in table1 and this reference number is in the other table multiple times. I wanted to have a field in Table1 (deposit amount) subtracted from a field in table2 (expected deposit) but in table2 there are multiple lines with the same reference number so I need those added up and then subracted from the same reference number in Table1. I can't even get the query to do a regular join between these two tables muchless get the math part working. Would rather use a query than VBA code because it has been 4 years since I did any real programming and that was under JAVA.

  2. #2
    jgelpi is offline Novice
    Windows XP Access 2003
    Join Date
    May 2009
    Posts
    19
    Try this...
    1)Create one query [SumQuery1], make it a Sum Query to Sum [Table2].
    2)Create a relationship between [Table1] and your [SumQuery1] - Just a standard relationship.
    3)Create a third Query [Query2] and add [Table1] and [SumQuery1] to it.
    4)Bring all fields from [Table1] and the Sum field from [SumQuery1].
    5)Create another field and use this expression:
    Diff: [SumOfAmount]-[Amount]
    where SumOfAmount is from your [SumQuery1] and Amount is from your [Table1]

  3. #3
    hokie is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2009
    Posts
    20
    when I do step 2 I get the same problem where the query returns no results. Could it be something related to the way the fields were imported from the outside source? They are like bank reference numbers but it is put in the table as 'text' since there are some exceptions....

    edit: could number stored as text be causing the problem?

  4. #4
    jgelpi is offline Novice
    Windows XP Access 2003
    Join Date
    May 2009
    Posts
    19

    Re: Do i need a custom program for this?

    It shouldn't matter. AS LONG AS the fields in both tables are the same (in your case, Text). One cannot be classified as text and the other as numeric, etc. I have included a copy of my example database.

  5. #5
    hokie is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2009
    Posts
    20
    Think i found the problem. It was imported from Excel so number as text had an (') in front of the numbers which created a space on the one table but for some reason the other table has no space in front of the numbers. Do you have any kind of quick way to correct this problem?

  6. #6
    jgelpi is offline Novice
    Windows XP Access 2003
    Join Date
    May 2009
    Posts
    19
    I have not heard of that. You're stating that when you import the data from Excel that it will come across as '153453x, or something of that nature? And that leading ' is not in the Excel file?

  7. #7
    hokie is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2009
    Posts
    20
    Yea but it replaced the ('12345) with ( 12345) space before the 12345. I donno but I've tested bringing in the same data and got it to import correctly without the space. I'll let you know how it works out now.
    thanks

  8. #8
    jgelpi is offline Novice
    Windows XP Access 2003
    Join Date
    May 2009
    Posts
    19
    Good to hear! I'm not sure why the data imported that way. Best of luck to ya!

  9. #9
    hokie is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2009
    Posts
    20
    Great it is working as I had imagined. Thanks for your help.

  10. #10
    jgelpi is offline Novice
    Windows XP Access 2003
    Join Date
    May 2009
    Posts
    19
    Glad it worked out for you!

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

Similar Threads

  1. Ticketing program for community theater
    By Bill in forum Database Design
    Replies: 8
    Last Post: 11-22-2012, 02:15 PM
  2. Replies: 4
    Last Post: 07-16-2009, 02:42 AM
  3. Set focus to another program
    By DrewB in forum Programming
    Replies: 1
    Last Post: 06-24-2009, 06:38 AM
  4. Program breaks after break was removed
    By Gene in forum Programming
    Replies: 3
    Last Post: 06-02-2009, 07:19 AM
  5. Need help - Record set based on a program variable
    By ericargent in forum Programming
    Replies: 1
    Last Post: 09-19-2007, 08:57 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