Results 1 to 4 of 4
  1. #1
    cknroman is offline Novice
    Windows 10 Access 2016
    Join Date
    Mar 2021
    Posts
    2

    Question Textbox to Control Source as well as Datediff function

    Hello all,

    I am a self taught Access guy. I have a form that has a textbox called 'Date Since RREP Approved' that I want to control a table field as well as preform a datediff function.

    datediff("D",now(),[RREP Approved Date])

    If I put that function in the control source I get the number of days since the RREP Approval Date. However I cant get it to update my table. Can someone help me with this?



    Furthermore, I have a drop down box named 'Status'. When I select 'Completed' I'd like the 'Date Since RREP Approved' textbox to stop the datediff function. Is this possible?

    Thanks in advance!

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,555
    I would set your field in the BeforeUpdate event of the form if you do it that way, else use the table field and set the control on a new record?
    On the AfterUpdate event of Status, check if Completed and if it is do whatever your are talking about to 'Date Since RREP Approved' textbox to stop the datediff function' ?

    It is possible if you use the second option to update the the Approval date, then that might take care of itself?
    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

  3. #3
    cknroman is offline Novice
    Windows 10 Access 2016
    Join Date
    Mar 2021
    Posts
    2
    Thanks! I was able to get the Date Since RREP Approved to update the source with the Datediff.

    I am not understanding what you mean about the afterupdate... check if completed. I dont know how to afterupdate if [Status]=completed then stop [date since rrep approved],beforeupdate.

    Not sure if that makes sense...

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,555
    I think the easiest option would be to set that control from your datediff formula in the Forms Current event IF the status is not Completed?
    Also if you are not interested in the time element, I would use Date, otherwise you could come into problems if you start looking for records 5, 10 or 15 days old etc?
    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

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

Similar Threads

  1. Replies: 9
    Last Post: 12-15-2016, 07:31 PM
  2. Textbox Control Source
    By asmores in forum Access
    Replies: 5
    Last Post: 02-19-2015, 09:59 AM
  3. Change a Control Source of a textbox VBA
    By WickidWe in forum Forms
    Replies: 1
    Last Post: 01-05-2014, 03:01 PM
  4. Replies: 17
    Last Post: 02-08-2012, 10:06 AM
  5. Textbox Control Source As An Expression help!
    By emilyrogers in forum Forms
    Replies: 11
    Last Post: 02-11-2011, 07:31 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