Results 1 to 6 of 6
  1. #1
    tlfowler4 is offline Novice
    Windows Vista Access 2007
    Join Date
    Aug 2013
    Posts
    2

    General Access Field Help

    Hi my name is Troy. I work for the Army, and my boss is having me build an Excel based spreadsheet in Access. He wants to be able to put a Date in Field 1, a Date in Field 2, and have Field 3 give the difference between the dates. I know how to put formulas into Excel, but Access is completely foreign to me. I tried importing an Excel spreadsheet, but it seems like all of the formulas go away once imported. I can give my email address, if someone is willing to answer questions I have one on one. I'm sure I will have a whole lot more after this one.

  2. #2
    TG_W is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2010
    Location
    Manvel, TX
    Posts
    299
    Import the table with the three columns (Fields in Access). Create a form based on the table and add the 3 Fields in Text Boxes. Add an After Update VBA that can calculate the difference and save all 3 dates.

    To add the coding, in the Form design view, click on the 'Event' tab in the 'Properties Sheet' (access this by pressing F4 key if not already open). Left-click on the "..." in the right of the After Update box. Add the code below for both Date 1 and Date 2 boxes to allow for the update if he changes one or the other, changing the names to match your text box names in the code.

    Code:
    [DateTextBoxNameHere] = DateDif("d",[Date1TextBoxNameHere],[Date2TextBoxNameHere])
    I'll try to upload a sample database shortly.
    Last edited by TG_W; 08-06-2013 at 09:47 AM. Reason: Wrong quotes.

  3. #3
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    Hi Troy, and welcome to the forum.
    Access is not a spreadsheet and can not be used as one.
    Use 2 fields in a table to store date1 and date2.
    Use a form that is bound to the table with three text box controls to add/edit data in the table.
    The first 2 text boxes should be bound to the Date1 and Date2 fields. The third field should have an expression as its Control Source that calculates the the difference between the two dates. Something like:
    = DateDiff("d", Date1, Date2)
    The third date is a calculation, so this would normally be calculated whenever and where ever required with the expression supplied.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  4. #4
    TG_W is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2010
    Location
    Manvel, TX
    Posts
    299
    I updated my code in the previous post since I put the wrong quotation marks (should have been " not ').

    Anyway, sample attached.
    Attached Files Attached Files

  5. #5
    tlfowler4 is offline Novice
    Windows Vista Access 2007
    Join Date
    Aug 2013
    Posts
    2
    I don't even know how to create a form like you are saying. I see the form button, but have know clue about the rest of it..

  6. #6
    TG_W is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2010
    Location
    Manvel, TX
    Posts
    299
    Well, you can left-click on the Table, then left-click on 'Form' in the 'Create' tab of the ribbon, and it will automatically create a form that can be edited after. You can also left-click 'Form Design' and bring everything in you want and arrange it as you want from the beginning.

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

Similar Threads

  1. General Access questions - can or cannot
    By Armitage2k in forum Access
    Replies: 2
    Last Post: 11-28-2011, 07:28 PM
  2. General question about access
    By TEE in forum Access
    Replies: 2
    Last Post: 05-30-2011, 07:50 AM
  3. Convert field to General Number
    By newtoAccess in forum Queries
    Replies: 1
    Last Post: 04-13-2011, 04:54 PM
  4. Replies: 1
    Last Post: 01-30-2010, 04:45 PM
  5. General Access Question
    By erose1987 in forum Access
    Replies: 1
    Last Post: 04-01-2009, 12:37 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