Results 1 to 12 of 12
  1. #1
    matey56 is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Jul 2020
    Posts
    136

    Updating fields in form based on date field

    Hi all,
    I have 4 fields on my form (see below) that I'm working on.

    Click image for larger version. 

Name:	Capture.JPG 
Views:	22 
Size:	42.1 KB 
ID:	48000


    Here's what I want to do:

    1. User enters date into "Date_Zipped" field


    2. Box pops up warning message to user "This will permanently move # to Previous Label Version. Are you sure you want to continue?"
    3. Existing label number in "Latest_Label_Released" will be moved/copied to both "Version_on_CDMS" and "Previous_Label_Version" fields. The "Latest_Label_Released" field will now be blank.
    4. The action will repeat every time a new date is entered. If the "Latest_Label_Released" field is blank, then nothing happens.

    I'm not good with VB script. Can someone help me out?

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,522
    i would add an unbound date field for user to enter this date: txtDateIn
    hide the actual txtDateZipped

    this way if the user answers NO to the prompt, you do nothing.
    if YES, add then do your script:

    Code:
    sub txtDateIn_Afterupdate()
    if msgbox("Are you sure you want to continue?",vbYesNo ,"Confirm") = vbNo then exit sub
     
    'new record?
    DoCmd.GoToRecord , , acNewRec
    
    txtZipDate =  txtDateIn 
    
    'more field assignements
    
    end sub

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,892
    Do you want to modify values in record?

    Code in date textbox AfterUpdate event, something like:
    Code:
    With Me
        If Not IsNull(.tbxLatest) Then
            .tbxCDMS = .tbxLatest
            .tbxPrevious = .tbxLatest
            .tbxLatest = Null
        End If
    End With
    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.

  4. #4
    matey56 is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Jul 2020
    Posts
    136
    Quote Originally Posted by June7 View Post
    Do you want to modify values in record?

    Code in date textbox AfterUpdate event, something like:
    Code:
    With Me
        If Not IsNull(.tbxLatest) Then
            .tbxCDMS = .tbxLatest
            .tbxPrevious = .tbxLatest
            .tbxLatest = Null
        End If
    End With
    This works perfectly, thanks! One more question, is there a way to bold certain parts of the MsgBox?

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,892
    None that I know of.
    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.

  6. #6
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Office 365
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,973
    Quote Originally Posted by matey56 View Post
    This works perfectly, thanks! One more question, is there a way to bold certain parts of the MsgBox?
    Yes there is. See Formatted Message Box (isladogs.co.uk)
    Or if you want additional functionality, use a task dialog message or create your own custom message form. See Attention Seeking Database (isladogs.co.uk)
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  7. #7
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,776
    Colin; interesting & have to wonder why Eval does that. I understand that Eval invokes the expression service message box instead of the vba message box function but that doesn't explain why it bolds text. Have you ever tried to bold individual words in the message by wrapping Eval's in Eval's? Wondering if that could reproduce something like:

    My dog does not have fleas!

    EDIT - I'm thinking not. Eval function cannot accept a simple string argument. In the bold message box code, Eval is being passed a function (msgbox) which is handling the string. Perhaps if there was a function that would accept a string without modifying it, a nested Eval might work. What comes to mind is Left("does not",8).
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,892
    More info at https://www.tek-tips.com/viewthread....2%20character.

    Be sure to follow the links in last 2 posts.
    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.

  9. #9
    matey56 is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Jul 2020
    Posts
    136
    Now the users are asking if the action of moving the data in the fields and the pop-up msgbox can not happen if the date is deleted. In other words, if the user deletes the date nothing happens at all.....just the removal of the date. How do I code that?

    Quote Originally Posted by June7 View Post
    Do you want to modify values in record?

    Code in date textbox AfterUpdate event, something like:
    Code:
    With Me
        If Not IsNull(.tbxLatest) Then
            .tbxCDMS = .tbxLatest
            .tbxPrevious = .tbxLatest
            .tbxLatest = Null
        End If
    End With

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,892
    Wrap that code in another If Then

    With Me
    If Not IsNul(.tbxDate) Then
    'code
    End If
    End With

    Or maybe a single If Then
    If Not IsNull(.tbxDate) AND Not IsNull(.tbxLatest) Then
    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.

  11. #11
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Office 365
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,973
    Hi Micron
    The formatted message box can only bold the first section of the message.
    If you need something more complex, then the best solution is a customised message form using rich text.
    Or as already mentioned, task dialog messages can be used.
    One more possibility is Cypris' lookout » MS Access: Enhanced Message Box Replacement (nkadesign.com) which also uses rich text.
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  12. #12
    matey56 is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Jul 2020
    Posts
    136
    Sorry, I'm slow. Below is the code I have. Where are you saying to add the new code?

    Private Sub Date_Zipped_to_Mfg_AfterUpdate()
    If MsgBox("Are you sure?", vbYesNo, "Confirm") = vbNo Then Exit Sub
    With Me
    If Not IsNull(.Date_Zipped_to_Mfg) Then
    .Version_on_CDMS_and_Current_at_States = .Latest_Label_Released_for_Prod
    .Previous_Label_Version = .Latest_Label_Released_for_Prod
    .Latest_Label_Released_for_Prod = Null
    End If
    End With
    End Sub

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

Similar Threads

  1. Replies: 5
    Last Post: 01-23-2021, 12:41 PM
  2. Replies: 3
    Last Post: 08-25-2016, 09:12 AM
  3. Replies: 5
    Last Post: 03-31-2016, 03:17 PM
  4. Replies: 1
    Last Post: 02-27-2015, 05:03 PM
  5. Updating one date field based on another
    By barryg80 in forum Forms
    Replies: 4
    Last Post: 04-19-2013, 03:17 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