Results 1 to 5 of 5
  1. #1
    zugapy is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2014
    Posts
    5

    I want to add record history to Table by command button

    I want to add record history to Table by command button but i don't know how to.
    On Asset Table will keep only current data that who borrowed asset at that moment but not enough, so i would like to keep history about borrowing and returning of asset.

    Description:

    When type Date Borrowed and press add to history button, the record of borrowing will be recorded in History Table.
    Click image for larger version. 

Name:	2014-03-15_194943.png 
Views:	10 
Size:	70.0 KB 
ID:	15761



    Result of History
    Click image for larger version. 

Name:	2014-03-15_195602.png 
Views:	10 
Size:	1.9 KB 
ID:	15762

    When type Date Returned and press add to history button, the record of borrowing will be recorded in History Table.

    Click image for larger version. 

Name:	2014-03-15_195856.png 
Views:	10 
Size:	34.0 KB 
ID:	15763

    Result of History

    Click image for larger version. 

Name:	2014-03-15_195548.png 
Views:	10 
Size:	3.0 KB 
ID:	15764



    I never use Ms Access and don't know about macro. I starting learn about it. Anyone, Please help me.


    File attachment: www78.zippyshare.com/v/902516/file.html

    Thank you very much.



  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Reminds me of the LendingLibrary database. It keeps history of items checked in and out. You should look at that template for ideas.
    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
    robrich22's Avatar
    robrich22 is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Feb 2013
    Location
    Louisville, KY
    Posts
    41
    Goto Form
    Right Click on "History" Button
    Select Properties
    Select Events
    Select "On Click" Event. Click on the dots "..."
    Select "Code Builder"
    Paste the code in the Click Event.
    Click Save Button. Click Exit VBA editor, and you should be good.

    Code:
       Dim sql As String
    
    
    On Error GoTo ErrHandler:
        sql = "INSERT INTO [History] (AssetID, AssetCategoryID, EmployeeID, DateBorrowed, DateReturned) " _
            & "VALUES (" & Me.AssetID.Value & ", " & Me.AssetCategoryID.Value & ", " & Me.EmployeeID.Value & ", #" & TimeValue(Me.DateBorrowed) & "#, #" & DateValue(DateReturned) & "#)"
        DoCmd.RunSQL (sql)
        MsgBox "History Added!"
        Exit Sub
    ErrHandler:
        MsgBox "Missing or incorrect information.  Check to ensure all fields have proper data and try again."
        Exit Sub

  4. #4
    zugapy is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2014
    Posts
    5
    Quote Originally Posted by robrich22 View Post
    Goto Form
    Right Click on "History" Button
    Select Properties
    Select Events
    Select "On Click" Event. Click on the dots "..."
    Select "Code Builder"
    Paste the code in the Click Event.
    Click Save Button. Click Exit VBA editor, and you should be good.

    Code:
       Dim sql As String
    
    
    On Error GoTo ErrHandler:
        sql = "INSERT INTO [History] (AssetID, AssetCategoryID, EmployeeID, DateBorrowed, DateReturned) " _
            & "VALUES (" & Me.AssetID.Value & ", " & Me.AssetCategoryID.Value & ", " & Me.EmployeeID.Value & ", #" & TimeValue(Me.DateBorrowed) & "#, #" & DateValue(DateReturned) & "#)"
        DoCmd.RunSQL (sql)
        MsgBox "History Added!"
        Exit Sub
    ErrHandler:
        MsgBox "Missing or incorrect information.  Check to ensure all fields have proper data and try again."
        Exit Sub
    Thank you for your help. It's work well.

  5. #5
    zugapy is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2014
    Posts
    5
    Quote Originally Posted by June7 View Post
    Reminds me of the LendingLibrary database. It keeps history of items checked in and out. You should look at that template for ideas.
    Thank you for your suggestion.

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

Similar Threads

  1. Replies: 3
    Last Post: 03-07-2012, 09:49 AM
  2. Replies: 4
    Last Post: 07-22-2011, 12:52 PM
  3. Replies: 3
    Last Post: 02-01-2011, 07:15 AM
  4. Updating another record table with command button
    By erlan501 in forum Programming
    Replies: 5
    Last Post: 04-26-2010, 09:03 AM
  5. Command button help - delete record
    By Zukster in forum Forms
    Replies: 0
    Last Post: 08-27-2009, 08:47 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