Results 1 to 7 of 7
  1. #1
    FormerJarHead is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Posts
    52

    Calculate a column in a query

    Hi All,

    I think I have created a very unique problem for myself. Since I do not know how to write code, I was hoping to do my calculations through queries but I've come to the conclusion...I don't think it's possible.

    In one of my forms (Form 1) I am getting information from a combo box and filling a field called [Replacing] which gives me an inmates name. I am also filling in another field (Date)on the same form using the same combo box. To get that field to populate with the info, I'm using [Replacing].[Column](2). (2) being the column with the date. This works well.

    This form gets its data from a query that includes data from another table. In this query I have create an expression in a column: Completion DateateAdd("d",+179,[AdmitDate]). This gives me the date an inmate will be released from custody after they complete the 180 day program. There is another column with an expression in this query: Date:[Completion Date]-[Referral Date]. This gives me the number of days an inmate will need to wait to get into the program.



    My problem is this: The calculations work. They just don't work correctly. For example: If Inmate Jones gets replaced on 10/4/12 by inmate Smith, I want to be able to calculate on Inmate Jones release date. Instead, it pulls in inmate Whites data. Inmate White is the first in the datasheet view. And it just goes down the list.

    I've rambled enough. If this makes any sense and you have any words of wisdom, I will certainly welcome them. If you need to see this db, I can send it along as well.

    Thank you for any help.
    Attached Files Attached Files

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    I don't understand why you have to track that 'this inmate replaces that inmate'. One inmate leaves, one inmate comes in. Why are these two events associated?

    If you want to calculate the earliest date a new inmate can enter the program (when a vacancy will open up), then that is easy enough, but it is irrelevant to this determination who is departing on that earliest date, the who would be incidental information.

    frmClient is a very loooong form. You might consider using tab control for more compact organization of controls.
    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
    FormerJarHead is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Posts
    52

    Red face

    Thanks June7 for responding. The program will only be able to house 32 inmates at any one time. We have over 1500 inmates in custody but not all will qualify for the program. What I was trying to accomplish between the 2 forms is to be able to show what the waiting time between an inmate already in the program(frmClient) and an inmate waiting to get into the program(frmWaitList) will be. I need to be able to show on the WaitList form the amount of time an inmate needs to wait based on the inmate he/she will be replacing. So in some way I need to perform a calculate where the "Projected Completion" date on frm Client subtracts the referral date on the frmWaitList and make sure that it is subtracting from the correct inmate and not just subtracting inmate 1, inmate 2 etc...

    I agree with your reccomendation also about using tab control. In fact, when I originally created this db that is how the form was designed. The Program Manager reminded me that cops will be inputing a lot of the info and I needed to make it more dummy friendly. We're both seeing her design...

    Quote Originally Posted by FormerJarHead View Post
    Hi All,

    I think I have created a very unique problem for myself. Since I do not know how to write code, I was hoping to do my calculations through queries but I've come to the conclusion...I don't think it's possible.

    In one of my forms (Form 1) I am getting information from a combo box and filling a field called [Replacing] which gives me an inmates name. I am also filling in another field (Date)on the same form using the same combo box. To get that field to populate with the info, I'm using [Replacing].[Column](2). (2) being the column with the date. This works well.

    This form gets its data from a query that includes data from another table. In this query I have create an expression in a column: Completion DateateAdd("d",+179,[AdmitDate]). This gives me the date an inmate will be released from custody after they complete the 180 day program. There is another column with an expression in this query: Date:[Completion Date]-[Referral Date]. This gives me the number of days an inmate will need to wait to get into the program.

    My problem is this: The calculations work. They just don't work correctly. For example: If Inmate Jones gets replaced on 10/4/12 by inmate Smith, I want to be able to calculate on Inmate Jones release date. Instead, it pulls in inmate Whites data. Inmate White is the first in the datasheet view. And it just goes down the list.

    I've rambled enough. If this makes any sense and you have any words of wisdom, I will certainly welcome them. If you need to see this db, I can send it along as well.

    Thank you for any help.

  4. #4
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    Can you post a prior version of access I'd like to take a look as well

  5. #5
    FormerJarHead is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Posts
    52
    Quote Originally Posted by rpeare View Post
    Can you post a prior version of access I'd like to take a look as well
    Not quite sure what you're asking me to do...I only have 2010

  6. #6
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    You can convert a database to a prior version, just click on the windows symbol in the upper left, hover over 'save as' and different versions you can convert to should appear in a list.

  7. #7
    FormerJarHead is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Posts
    52
    Copy. Unfortunately with this being a County Computer, they lock me out of a lot of the options. I did however find the answer to my problem. I needed to write a small sting of code Me.WaitTime = DateDiff("d", ReferralDate, Rep). Works as it should. I want to thank all who took the time to look and offer assistance...Stay Safe

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

Similar Threads

  1. Calculate Date in Query
    By raytackettsells in forum Programming
    Replies: 8
    Last Post: 03-23-2012, 01:44 PM
  2. Calculate Percentage based on previous column
    By VictoriaAlbert in forum Queries
    Replies: 1
    Last Post: 08-13-2011, 01:30 PM
  3. Replies: 7
    Last Post: 04-27-2010, 02:47 PM
  4. Calculate average in a query
    By srbooth in forum Queries
    Replies: 1
    Last Post: 02-20-2010, 09:41 AM
  5. Calculate problem in query
    By crujazz in forum Queries
    Replies: 2
    Last Post: 06-15-2009, 08:03 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