1. Welcome! Please take a few seconds to create your free account to post threads, make some friends, remove a few ads while surfing and much more. ClutchFans has been bringing fans together to talk Houston Sports since 1996. Join us!

Microsoft Access Help.

Discussion in 'BBS Hangout' started by Lil Pun, Nov 21, 2005.

Tags:
  1. Lil Pun

    Lil Pun Member

    Joined:
    Oct 6, 1999
    Messages:
    34,143
    Likes Received:
    1,038
    If anybody on this board knows about Microsoft Office's Access your help would be greatly appreciated. I am setting up a database using Access which involves entering dates but I need future dates calculated. Here is an example:

    One field is called Current 90 Day Date and what I need is a date to be entered such as 11/21/2005 but the date 90 days after this date to be displayed in another field which would be called 90 Day Due Date. There are a few other fields I need to do this in too. Is there anyway to set up a field so it will calculate dates at all?
     
  2. bobrek

    bobrek Politics belong in the D & D

    Joined:
    Sep 16, 1999
    Messages:
    36,288
    Likes Received:
    26,645
    Check out the "DateAdd" function.
     
  3. Lil Pun

    Lil Pun Member

    Joined:
    Oct 6, 1999
    Messages:
    34,143
    Likes Received:
    1,038

    Thanks, just got through checking it out but whenever I try and save my table I get an error "Type mismatch" message.

    I select the DateAdd funtion and it gives me this in the Default Value field:

    DateAdd («interval», «number», «date»)


    What do I substitute for interval, number, and date?

    I figured I put +90 in number because that is what I want. The I put the Current Date Field where date is but what do I put under interval.
     
  4. pirc1

    pirc1 Member

    Joined:
    Dec 9, 2002
    Messages:
    14,138
    Likes Received:
    1,882
    Interval is the time period you want to increment. This is the example in MSaccess:

    Expression Description
    =DateAdd("d", -10, [PromisedDate]) Displays a date that is 10 days before the value of the PromisedDate field.
    =DateAdd("m", 1, "31-Jan-03") Displays a date that is a month after 31-Jan-03, so the expression will evaluate to 28-Feb-03.
    =DateAdd("m", 1, "31-Jan-04") Displays a date that is a month after 31-Jan-04, and since 2004 is a leap year, the expression will evaluate to 29-Feb-04.
    =DateAdd("q", 3, [PromisedDate]) Displays a date that is three quarters after the value of the PromisedDate field; for example, if the value of the PromisedDate field is 18-Jun-03, the expression will evaluate to 18-Mar-04.
    =DateAdd("h", 3, [ArrivalTime]) Displays a time that is three hours after the value of the ArrivalTime field.

    You can use these expressions in a calculated field in a query.
     
  5. Lil Pun

    Lil Pun Member

    Joined:
    Oct 6, 1999
    Messages:
    34,143
    Likes Received:
    1,038
    OK under my table I have it set it 90DayDate and 90DayDue. In my Default Value field under 90DayDue I have the formula set up like this:

    =DateAdd("d",+90,[90DayDate])

    When I try to save the table I get this error message:

    The database engine does not recognize either the field '90DayDate' in a validation expression, or the default value in table PTable

    But I have I have two fields set up in PTable and those are the two listed above so what am I doing incorrectly?
     
  6. pirc1

    pirc1 Member

    Joined:
    Dec 9, 2002
    Messages:
    14,138
    Likes Received:
    1,882
    I think you should setup a query to update the table. I do not think you can use the function directly in defining the second field.
     
  7. Lil Pun

    Lil Pun Member

    Joined:
    Oct 6, 1999
    Messages:
    34,143
    Likes Received:
    1,038
    So where do I put the formula when making a query? I see Field Table Sort Criteria or but where do I put the formula?
     
  8. pirc1

    pirc1 Member

    Joined:
    Dec 9, 2002
    Messages:
    14,138
    Likes Received:
    1,882
    Lets say you create a table called table1 and have two fileds [dateone] and [datetwo] both defined as datetime. create a query called query one and paste this into the sql defination area:

    UPDATE Table1 SET Table1.datetwo = DateAdd("d",90,[dateone]);

    That will update the datetwo to 90 days after dateone.

    hope that helped
     
  9. Lil Pun

    Lil Pun Member

    Joined:
    Oct 6, 1999
    Messages:
    34,143
    Likes Received:
    1,038
    OK I set it up and here is what the query looks like in SQL view:

    SELECT [Practice Table].[90DayDate], [Practice Table].[90DayDue]
    UPDATE [Practice Table] SET 90DayDate.90DayDue = DateAdd("d",+90,[90DayDate])
    FROM [Practice Table];

    I get this error message: Syntax error (missing operator) in query expression '[Practice Table].[90DayDate] UPDATE [Practice Table] SET 90DayDate.90DayDue = DateAdd("d",+90,[90DayDate])'.
     
  10. pirc1

    pirc1 Member

    Joined:
    Dec 9, 2002
    Messages:
    14,138
    Likes Received:
    1,882

    Try this

    UPDATE [Practice Table] SET [90DayDue] = DateAdd("d",90,[90DayDate]);
     
  11. Lil Pun

    Lil Pun Member

    Joined:
    Oct 6, 1999
    Messages:
    34,143
    Likes Received:
    1,038
    Getting the same error message...
     
  12. pirc1

    pirc1 Member

    Joined:
    Dec 9, 2002
    Messages:
    14,138
    Likes Received:
    1,882
    Do you only have the following in the query?

    UPDATE [Practice Table] SET [90DayDue] = DateAdd("d",90,[90DayDate]);

    If that is the case I have no idea why it wouldn't work.
     
  13. Lil Pun

    Lil Pun Member

    Joined:
    Oct 6, 1999
    Messages:
    34,143
    Likes Received:
    1,038
    OK, that was the problem. I have other fields that I need dates calculated on also. Can I just add an UPDATE line to the SQL definition area under the query and do those that way too?
     
  14. pirc1

    pirc1 Member

    Joined:
    Dec 9, 2002
    Messages:
    14,138
    Likes Received:
    1,882
    You can update many fields with one query but you can not put two different queries in one place.
     
  15. Lil Pun

    Lil Pun Member

    Joined:
    Oct 6, 1999
    Messages:
    34,143
    Likes Received:
    1,038

    Do you have an example of updating more than one field with just one query?
     
  16. pirc1

    pirc1 Member

    Joined:
    Dec 9, 2002
    Messages:
    14,138
    Likes Received:
    1,882
    UPDATE [Practice Table] SET [Practice Table].[90DayDue] = DateAdd("d",90,[90DayDate]), [Practice Table].[120DayDue] = DateAdd("d",120,[90DayDate]);


    will update another field to 120 days from the original date.
     
  17. Stone Cold Hakeem

    Joined:
    Oct 26, 1999
    Messages:
    1,263
    Likes Received:
    89
    Try creating a query that includes the calculated field dates. For example, your table might contain the following field:

    Current90DayDate DateTime

    Now create a query and include the following:

    Current90DayDate This is the 90 Day date field from your table
    DateAdd("d",90,Current90DayDate) This formula will calculate a date 90 days from your Current90DayDate field

    This is the easiest way to display value. You don't not need store it in your table since it is simply a calculated value.

    Hope this helps
     
  18. Lil Pun

    Lil Pun Member

    Joined:
    Oct 6, 1999
    Messages:
    34,143
    Likes Received:
    1,038
  19. Stone Cold Hakeem

    Joined:
    Oct 26, 1999
    Messages:
    1,263
    Likes Received:
    89
    MS Access contains a Form Wizard that will provide the basic skeleton of an input form for your table, but it doesn't have any sort of menu wizard of which I am aware.

    What are you building, if you don't me asking?
     
  20. Lil Pun

    Lil Pun Member

    Joined:
    Oct 6, 1999
    Messages:
    34,143
    Likes Received:
    1,038
    A client database for a counseling company I am working for. Things are so disorganized at the moment I am trying to get at least a few things organized and if I can get the information set up about each client in an Access database that would help a bunch. Here is everything that I need listed in my database:

    Client ID, Payor Source Number, Date of Birth, First Name, Last Name, PCP Name, PCP Expiration Date, Therapist, Case Manager, Intake Date, Psych Eval Date, Last Psych Visit, 90 Day Due Date, Next 90 Day Due Date, 180 Day Date, Next 180 Day Date, PA Start Date, PA End Date, Level of Care, Diagnosis Axis I & Axis II.

    After getting this set up I was wondering is there a way to print out all information on a client for a specific therapist or case manager? Example:

    John Doe is assigned clients Jane Doe, Adam Doe, Beth Doe, and Carl Doe. Can I print out all information on those clients and not other ones stored in the database?
     

Share This Page

  • About ClutchFans

    Since 1996, ClutchFans has been loud and proud covering the Houston Rockets, helping set an industry standard for team fan sites. The forums have been a home for Houston sports fans as well as basketball fanatics around the globe.

  • Support ClutchFans!

    If you find that ClutchFans is a valuable resource for you, please consider becoming a Supporting Member. Supporting Members can upload photos and attachments directly to their posts, customize their user title and more. Gold Supporters see zero ads!


    Upgrade Now