Results 1 to 4 of 4
  1. #1
    pmontalt is offline Novice
    Windows 8 Access 2013
    Join Date
    Mar 2014
    Posts
    11

    Question Creating a New Record After Update

    Hello. Have a quick question that I can't seem to figure out...looking for some help.


    What I have:


    I have a table called [Tasks] which has the following relevant fields:


    [Task ID]
    [Location]


    I have a form that people use to create new tasks and update current ones. Location on the form is a combo box where people can pick from 5-6 different locations.


    What I want:


    After someone selects a new location from the combo box and changes the task location, I want to create a new record in a table called [Task Progress] with the [Task ID] of the task whose location was changed, the new [Location], and the [Date] and [Time] it was changed. It would look like


    Code:
    [Progress ID] [Task ID]  [Location]  [Date]     [Time]
    1               5        Station 1   1/1/2011  12:13:01
    2               8        Station 2   1/3/2011  01:53:29
    3               5        Station 2   1/5/2011  11:13:05
    4               5        Station 3   1/6/2011  12:35:22

    What should I put in the AfterUpdate event for the [Location] combobox to make the above happen? Thanks!




    Note: All my tables are ODBC linked to SQL Server (can't use data macros).

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,646
    Something like:

    CurrentDb.Execute "INSERT INTO [Task Progress] (Location, [Date], Time) VALUES('" & Me.Location & "', #" & Date() & "#, #" & Format(Now(), "hh:nn:ss") & "#")

    Why date and time in separate fields? Is Time a date/time or text field type?

    Date is a reserved word. Should avoid reserved words as field names.
    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
    pmontalt is offline Novice
    Windows 8 Access 2013
    Join Date
    Mar 2014
    Posts
    11
    Thanks!! :-)
    I created the date and time fields in SQL as Date and Time datatypes, and then linked it. I saw access treats them now as text fields. Should i just have one DateTime field as datatype datetime instead?

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,646
    One field should be easier to work with. This is one case where separate fields for data elements is not usually best.
    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.

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

Similar Threads

  1. Comcbo box creating new combo box after update
    By tyewonk in forum Database Design
    Replies: 7
    Last Post: 10-10-2013, 03:13 PM
  2. Replies: 4
    Last Post: 12-14-2012, 06:33 PM
  3. Replies: 1
    Last Post: 04-24-2012, 02:36 PM
  4. Creating an Update/Append Query
    By Jray9242 in forum Import/Export Data
    Replies: 2
    Last Post: 04-23-2012, 06:31 PM
  5. Creating unique record from record and field data
    By arthurpenske in forum Access
    Replies: 3
    Last Post: 08-24-2011, 06:11 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