Results 1 to 5 of 5
  1. #1
    ACKA200 is offline Novice
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2013
    Posts
    2

    Auto Populate multiple dates in form

    Hi,



    New access user here. I have designed a database to keep track of air ambulance calls. There are about 20 times that are tracked for each call. In order to calculate elapsed time for these calls (some of which occur over midnight) both the date and time would have to be entered in the field. Due to the high volume of information that is being entered, I am looking for a way to set the date once (or twice if the call spans midnight) and enter the times in independent of date. I have created fields in the table for example "date of arrival at scene" and "time of arrival at scene" which will be combined in the query to eventually calculate total time at scene.

    Ideally I would like for the user to select the date in the first field (date of call), and have that date automatically populate the remainder of the date fields in the form. If the date changes half way through the call (e.g. over midnight) the user adjust the date in the respective field and all dates below it change as well (the dates above this field would remain the same). I have tried setting the "default value" of subsequent fields to that of the previous field. When the first date field is entered, nothing shows up in the subsequent date fields. HOW DO I GET IT TO DO THIS?

    Further to this, I would like the date to be displayed in the form field as just the day of the date. e.g. 4/20/2013 would be shown as '20'. Can this be done while maintaining calender button functionality?

    Thank you in advance,

    AC

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    DefaultValue property only triggers when new record is first initiated so setting DefaultValue property for fields of current record doesn't work to populate the fields. If you want to set DefaultValue so the fields will populate in the next record, that is possible. Use the BeforeUpdate event of the textbox to set the DefaultValue property of each textbox.

    Post your attempted code for analysis.

    By calendar button do you mean calendar control? I've never used calendar control but try setting the Format property to "dd".
    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
    ACKA200 is offline Novice
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2013
    Posts
    2
    Thanks for the quick response!

    So it sounds like from what you are saying there is no way to for this to occur within the same record? e.g. If open a new blank form (record) and set the date in the first field, there is no way for the current record to populate the dates 'down' the fields?

    If that is the case, any suggestions on a quicker way to either enter the time and date for each field or calculate the midnight spanning more effectively?

    I do not have access on this computer so I cannot try it out.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Not sure what you mean by 'populate down'. What is 'down' if records don't yet exist? Set DefaultValue property by code then when next record is initiated the field will populate.
    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.

  5. #5
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    If I understand your requirements, you can use the AfterUpdate event of the first date Field to set the other date Fields 'down the line.' You can then do the same for each date Field, in turn. Here's an example using 4 date fields:
    Code:
    Private Sub DateField1_AfterUpdate()
     Me.DateField2 = Me.DateField1
     Me.DateField3 = Me.DateField1
     Me.DateField4 = Me.DateField1
    End Sub
    
    Private Sub DateField2_AfterUpdate()
     Me.DateField3 = Me.DateField2
     Me.DateField4 = Me.DateField2
    End Sub
    
    Private Sub DateField3_AfterUpdate()
     Me.DateField4 = Me.DateField3
    End Sub


    Linq ;0)>

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

Similar Threads

  1. Replies: 11
    Last Post: 01-25-2013, 12:03 PM
  2. Replies: 63
    Last Post: 09-16-2011, 04:55 PM
  3. Auto Populate form
    By fpsmi in forum Access
    Replies: 1
    Last Post: 09-16-2011, 09:24 AM
  4. Auto populate a field (without a form)
    By DonL in forum Access
    Replies: 1
    Last Post: 06-21-2011, 03:19 AM
  5. Auto populate form using combo box
    By bundy75 in forum Access
    Replies: 6
    Last Post: 08-29-2010, 06:18 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