Results 1 to 6 of 6
  1. #1
    twgonder is offline Expert
    Windows 10 Access 2021
    Join Date
    Jun 2022
    Location
    Colombia
    Posts
    658

    Change a textbox value in before update throws error

    Continuing on with my form,
    I'm trying to alter what a user entered, in a textbox, into a different string/value.
    Specifically, if a user enters a date as 13.4.5 16.7.8 then I want it converted to 2013/4/5 16:07:08


    (A funny side note, Access doesn't see an error with that input, put it swaps the time for the date and gives an unexpected result)

    My function returns a string for the correctly formatted "." date,
    but when I try to save it, anywhere, there's a run-time error (debug goes to the highlighted line).
    It seems odd that the textbox entry can't be altered.
    I've tried the .text, .value, control name and all give the same error.

    Click image for larger version. 

Name:	20221229Chng1.jpg 
Views:	21 
Size:	137.9 KB 
ID:	49389

    Am I going about this correctly?
    Is this something Access doesn't allow?
    Is there a better place to do this than in BeforeUpdate of the control?
    I've researched this on Google. and most of the problems/responses don't apply, but the few that do offer no solution.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,928
    If you want to modify the input, use AfterUpdate event.
    Where does sDtInputL come from?
    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
    twgonder is offline Expert
    Windows 10 Access 2021
    Join Date
    Jun 2022
    Location
    Colombia
    Posts
    658

    Not sure that will work

    Quote Originally Posted by June7 View Post
    If you want to modify the input, use AfterUpdate event.
    Where does sDtInputL come from?
    Most of the threads I read elsewhere, people started with the AfterUpdate, had the same problem and were told to use BeforeUpdate.
    There is further validation done after the change (like a range of permitted dates), so the data needs to be written to the various properties before update so it can be canceled.

    I'll give it a try anyways.

    sDtInputL is a function to modify the entered date.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,928
    Don't think I've ever needed BeforeUpdate. I use AfterUpdate to modify input. If you want to validate then use BeforeUpdate to either accept or cancel user input. Then use AfterUpdate to make change to user input. Example from my DB:

    Private Sub tbxFieldLL_AfterUpdate()
    Me.tbxFieldLL = UCase(Me.tbxFieldLL)
    End Sub
    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.

  5. #5
    moke123's Avatar
    moke123 is online now Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,654
    I think I would be inclined to force the user to input dates in the desired format rather than try to fix an improper entry.

    A funny side note, Access doesn't see an error with that input, put it swaps the time for the date and gives an unexpected result)
    Are you still using Date/Time extended?
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  6. #6
    twgonder is offline Expert
    Windows 10 Access 2021
    Join Date
    Jun 2022
    Location
    Colombia
    Posts
    658
    @ to all Thanks for the suggestions. I got a prototype that I'm testing now that seems to do most everything I wanted with entry validation, save validation and date entry. I would have liked to be able to enter early CE and BCE dates for historical figures and events, but that will have to wait for another day.

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

Similar Threads

  1. Runtime Error 3075: Apostrophe Throws an Error
    By besuchanko in forum Modules
    Replies: 3
    Last Post: 03-15-2022, 05:21 PM
  2. Replies: 7
    Last Post: 03-04-2021, 04:01 AM
  3. Repeated rebuild of right-click menu throws error
    By Petr Danes in forum Programming
    Replies: 1
    Last Post: 04-04-2019, 01:53 PM
  4. My code throws error 424. How do i work around this?
    By ThornofSouls in forum Programming
    Replies: 2
    Last Post: 09-11-2015, 06:30 AM
  5. change textbox value after combo update
    By arctushar@yahoo.com in forum Forms
    Replies: 5
    Last Post: 09-06-2010, 07:17 PM

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