Results 1 to 12 of 12
  1. #1
    Abugilda0 is offline Novice
    Windows 10 Office 365
    Join Date
    Jun 2020
    Posts
    8

    Use a command button to set a value in a record

    Hi,
    I would like to use a command button to set current time in the selected text box in a form
    Moreover, when I move to the next field i would like the previous value to be stored in the record (saved)


    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,545
    Perhaps:
    Me.[TextBoxName] = Time()
    in the On Click event of the button
    And
    If Me.Dirty Then Me.Dirty = False
    in the Got Focus event of the "next field" textbox.
    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
    Abugilda0 is offline Novice
    Windows 10 Office 365
    Join Date
    Jun 2020
    Posts
    8
    Hi,
    Probably did something wrong
    Click image for larger version. 

Name:	error massage.png 
Views:	23 
Size:	21.6 KB 
ID:	47431


  4. #4
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,545
    Quote Originally Posted by Abugilda0 View Post
    Hi,
    Probably did something wrong
    Ah...but you're not telling us what you did do.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  5. #5
    Abugilda0 is offline Novice
    Windows 10 Office 365
    Join Date
    Jun 2020
    Posts
    8
    Thanks Bob,
    I have copied the syntax you gave me to the on click event of the button (Changed the name to the field in my table)
    I get an error massage that it doesn't recognize what is Me (It want to run a macro or provide a macro name)

  6. #6
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,545
    Have you just pasted it onto the space on the Property Sheet?
    It needs to be in the form's code module.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  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,545
    Further to my last post I have attached an example database.
    Attached Files Attached Files
    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
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    5,033
    Quote Originally Posted by Abugilda0 View Post
    Thanks Bob,
    I have copied the syntax you gave me to the on click event of the button (Changed the name to the field in my table)
    I get an error massage that it doesn't recognize what is Me (It want to run a macro or provide a macro name)
    Most developers stay away from macroes, as they are limited compared to VBA.
    I have only used them for batch processes and learnt VBA (as you should )

    In Access 2007 you would use
    Attached Thumbnails Attached Thumbnails macroDate.PNG  
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  9. #9
    Abugilda0 is offline Novice
    Windows 10 Office 365
    Join Date
    Jun 2020
    Posts
    8
    Thanks Bob so much
    You probably figured that I'm still have large gaps of knowledge
    I followed your instructions and even used your DB example
    Still I'm getting this:
    Microsoft Access cannot find the object Me
    If 'Me' is a new Macro group, make sure you have saved it and that you have typed its name correctly
    What can it be please

  10. #10
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,545
    Quote Originally Posted by Abugilda0 View Post
    Thanks Bob so much
    You probably figured that I'm still have large gaps of knowledge
    I followed your instructions and even used your DB example
    Still I'm getting this:
    Microsoft Access cannot find the object Me
    If 'Me' is a new Macro group, make sure you have saved it and that you have typed its name correctly
    What can it be please
    This sounds to me as though you are trying to use a macro in some way.
    Like many others here I have little to do with macros, preferring the use of vba code.
    Post a copy of your db so that we can determine what is wrong.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  11. #11
    Abugilda0 is offline Novice
    Windows 10 Office 365
    Join Date
    Jun 2020
    Posts
    8
    Thanks so much
    I have attached the DB
    Attached Files Attached Files

  12. #12
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,545
    As far as I can see, your only problem is that in the property sheet for the button's On Click event you have:
    Code:
    Me.[Text16] = Time()
    but you should have:
    Code:
    [Event Procedure]
    as you have in the Got Focus event of the textbox named txtTimeEnd.
    You already have the correct code in the form's code module for each of the afore mentioned events.
    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. Adding a record will add a command button
    By NickWren in forum Programming
    Replies: 8
    Last Post: 04-04-2017, 07:11 PM
  2. Replies: 3
    Last Post: 10-04-2013, 06:24 AM
  3. Replies: 4
    Last Post: 07-22-2011, 12:52 PM
  4. Replies: 1
    Last Post: 07-27-2010, 02:27 PM
  5. Command button help - delete record
    By Zukster in forum Forms
    Replies: 0
    Last Post: 08-27-2009, 08:47 AM

Tags for this Thread

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