Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2009
    Posts
    3

    Unanswered: Access Command Button to Enter System Time

    I have a database that I need to create a reusable command button to enter the system time and one for date in a form then save that data to the table.
    I have to add several fields to track testing on many test run on samples taken in.
    The database needs to have start and stop times and dates for all tests fields.

    I am also curious if the command button for each field can be made to change from a caption of start test to end test when start test is clicked.

    I would very much appreciate your time and input on creating these buttons, and thank you for the help if you can offer some.

    Database is attached.
    Attached Files Attached Files

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    You do not really need a button. As I can see when examinning your database, you tried to use the doubleclick event. You can do so like this:

    Code:
    Private Sub TESTS_START_Txt_DblClick(Cancel As Integer)
    
        Me.ActiveControl = Now
        
    End Sub
    Or if you prefer to place the call in the properties window:

    1. Create an independant module (not the class module of the form) and place the following function in it:
    Code:
    Public Function SetTime()
    
        Dim ctl As Control
        
        Set ctl = Screen.ActiveControl
        ctl.Value = Now
        
    End Function
    Now in the properties windows of the TESTS_START_Txt control, for instance, you can call the SetTime() function. On the On Dbl Click line, place:
    Code:
    =SetTime()
    Have a nice day!

  3. #3
    Join Date
    Aug 2009
    Posts
    3

    Access 2002 (XP) not 2007

    I attempted to copy this to my database but it does not work.
    I receive an error message when attempting to enter the date with both methods.
    The error satates something to the effect that "Access cannot interpret the underlying code because ia function, macro or procedure is missing".
    Does this solution apply to Access v 2003 or higher?
    I am using Access v 2002 (XP).
    I left the version information out of the first post and it seems that may be a problem.

    Thank you again for any help that may be offered.

  4. #4
    Join Date
    Aug 2009
    Posts
    3

    Access 2002 (XP) not 2007

    I attempted to copy this to my database but it does not work.
    I receive an error message when attempting to enter the date with both methods.
    The error satates something to the effect that "Access cannot interpret the underlying code because ia function, macro or procedure is missing".
    Does this solution apply to Access v 2003 or higher?
    I am using Access v 2002 (XP).
    I left the version information out of the first post and it seems that may be a problem.

    The problem is more than likely because I do not have enough experience in programming Access and just do not understand how to make it work correctly.

    Thank you again for any help that may be offered.

  5. #5
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    Skier,

    I've tested it in Access 2000 (sp3) and in Access 2003 (sp3) and it works in both cases, so I suppose it should also work in Access 2002. Please verify if there isn't a missing reference: Open a module and in the Option menu select References. In the References window see if no line is marked as "Missing".

    Have a nice day!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •