Results 1 to 6 of 6
  1. #1
    Shawie is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2013
    Posts
    3

    Withholding Period

    I have build a database cattle handling.
    I have a table called Treatment Table,this has fields Date of Treatment, Withholding Days and Withholding Date
    I have created a sub-form for this table, and I am trying to add the Withholding Days to the Date of Treatment to come up with a future date.

    I am new at this and struggling.


    Ta

    Shawie

  2. #2
    recyan's Avatar
    recyan is offline Expert
    Windows 2K Access 2000
    Join Date
    Dec 2011
    Posts
    662
    Guess, you will have to post more details about your db.
    For eg.
    tblTreatments
    DateOfTreatment
    WitholdingDays
    WithholdingDate

    Which is the primary key?
    Are there any other tables involved ?
    If yes, what are the relationships ?
    Why are you using Sub-Form ?

    A textual description of what your db does & what is the role of each table will be more helpful, for people to help.

    Thanks

  3. #3
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Try this ... create a new query:
    Code:
    SELECT DateOfTreatment, WitholdingDays, WithholdingDate, DateAdd("d", WitholdingDays, DateOfTreatment) AS FutureDate FROM tblTreatments
    This calculated future date should not be stored in the table because it can be calculated at any time.



    Also, as in the field names recyan posted, you shouldn't use spaces or special characters (except the underscore) in object names.

  4. #4
    Shawie is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2013
    Posts
    3
    I have a number of sub-forms within a form
    In the sub-form Treatment property sheet (control source) I just want to put a formula in this to calculate a future date

    Date of Treatment/Withholding Days/Withholding Period(Future Date) The withholding date changes depends on treatment.
    1/1/2013 * 23 = 24/1/2013


    I have already completed a formula for my breeding sub-form which works
    =DateSerial(Year([StartDate]),Month([StartDate])+9,Day([StartDate])+10)

    Ta

  5. #5
    Shawie is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2013
    Posts
    3
    I have a number of sub-forms within a form
    In the sub-form Treatment property sheet (control source) I just want to put a formula in this to calculate a future date

    Date of Treatment/Withholding Days/Withholding Period(Future Date) The withholding date changes depends on treatment.
    1/1/2013 * 23 = 24/1/2013


    The withholding days varies depending on treatment, I have tried the following formula, but it dosen't seem to work =DateAdd("d",[WithholdingDays],[DateofTreatment])

    I have already completed a formula for my breeding sub-form which works
    =DateSerial(Year([StartDate]),Month([StartDate])+9,Day([StartDate])+10)


    Any help would be appreciated.

    shawie

  6. #6
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    The sub-form Treatment recordsource should be a query, not a table. The query looks like:
    Code:
    SELECT DateOfTreatment, WitholdingDays, DateAdd("d", WitholdingDays, DateOfTreatment) AS FutureDate FROM tblTreatments
    Change the table name (in BLUE) to your table name.
    Bind "FutureDate" to the control on the form to display the future date.



    If you must use a calculated control, the formula would look like:
    Code:
    = DateAdd("d", NameOfWitholdingDaysControl, NameOfDateOfTreatmentControl)
    Change the control names (in BLUE) to your control names.

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

Similar Threads

  1. How do I store a period of time
    By OscarCat in forum Access
    Replies: 2
    Last Post: 06-10-2012, 05:08 PM
  2. I just DON'T know how to relate Tables - PERIOD!
    By djclntn in forum Database Design
    Replies: 6
    Last Post: 02-26-2012, 07:21 PM
  3. How can i know existing period
    By waqas in forum Forms
    Replies: 1
    Last Post: 09-19-2011, 11:36 AM
  4. Getting Tax Period from current date
    By crxftw in forum Forms
    Replies: 3
    Last Post: 07-09-2011, 07:12 AM
  5. Allow a period in a table field name
    By escapades_access in forum Database Design
    Replies: 9
    Last Post: 07-08-2011, 09:21 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