Results 1 to 9 of 9
  1. #1
    Itzik B is offline Novice
    Windows 10 Office 365
    Join Date
    Jun 2020
    Location
    Israel
    Posts
    2

    Assign a date/time value with button

    Hi,


    I have a empty table with 3 columns
    Start time, End time, Comment
    I would like to press a button to fill the start time - only for the beginning of the observation
    The next time I press a button i would like to set the value to the end time field
    In addition: I would like the record to be set on the next line as start time

    I am an amateur: do not know where to start

    Thanks in Advance

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,530
    Create a form, with three text box controls, bound to the table.
    Create a button on the form.
    You will need code in the buttons On Click event to determine which text box needs to be filled using the Now() function
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,530
    BTW Your table will probably need a Primary Key field added to it. You would need a text box on the form for that as well.
    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
    Itzik B is offline Novice
    Windows 10 Office 365
    Join Date
    Jun 2020
    Location
    Israel
    Posts
    2
    Dear Bob, Thanks so much, I will try to elaborate
    I have this form
    Labels represent Actions
Command buttons represent sub actions
    I also have 3 tables
    Click image for larger version. 

Name:	Table actions.JPG 
Views:	17 
Size:	28.4 KB 
ID:	42292
    Click image for larger version. 

Name:	Sub actions.JPG 
Views:	17 
Size:	66.6 KB 
ID:	42293
    Click image for larger version. 

Name:	Observation data.JPG 
Views:	17 
Size:	36.2 KB 
ID:	42294
    Click image for larger version. 

Name:	Relationship.JPG 
Views:	17 
Size:	47.7 KB 
ID:	42295
    I would like to store the data in the table observation data by using the command buttons
    Is it possible?

  5. #5
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,530
    Yes. As I said in my first post create a form. It would need to be in "Single" or "Continuous" view because you can't have a button on a form in "Datasheet" view.
    Add the following code to the button's On Click event.
    Code:
        If IsNull(Me.[Start Time]) Then
            Me.[Start Time] = Now()
        ElseIf IsNull(Me.[End Time]) Then
            Me.[End Time] = Now()
        End If
    BTW You appear to have spaces in the names of some fields and tables. This is not considered to be "Good Practice" so I would advise that you change names like "Start Time" to "StartTime" or Start_Time".
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  6. #6
    Abugilda0 is offline Novice
    Windows 10 Office 365
    Join Date
    Jun 2020
    Posts
    8
    Thank you so much Bob
    For teaching and guiding me
    I will try what you have showed me and try to move from there
    Have a lovely weekend

  7. #7
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,530
    Quote Originally Posted by Abugilda0 View Post
    Thank you so much Bob
    For teaching and guiding me
    I will try what you have showed me and try to move from there
    Have a lovely weekend
    Thank for your kind words. Let us know how you get on.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  8. #8
    Abugilda0 is offline Novice
    Windows 10 Office 365
    Join Date
    Jun 2020
    Posts
    8
    Hi Bob,
    I still do not know how to make the data that coming from the command button will be recorded at the observation data table in the start time field
    Can you advice please?
    Itzik

  9. #9
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,530
    Quote Originally Posted by Abugilda0 View Post
    Hi Bob,
    I still do not know how to make the data that coming from the command button will be recorded at the observation data table in the start time field
    Can you advice please?
    Itzik
    The button is used to enter the data into a text box on the form. The text box is bound to a field in the forms Record Source (table/query).
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

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

Similar Threads

  1. Replies: 3
    Last Post: 05-09-2019, 07:31 AM
  2. On Button Click, Record Date & Time to a Textbox
    By JakeMurray27 in forum Programming
    Replies: 2
    Last Post: 02-20-2016, 04:22 AM
  3. Assign F5 function to a button
    By eduardo in forum Forms
    Replies: 4
    Last Post: 06-24-2012, 08:21 AM
  4. Replies: 6
    Last Post: 02-09-2010, 07:53 AM
  5. Command button for time & date
    By joet5402 in forum Forms
    Replies: 2
    Last Post: 12-20-2007, 02:59 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