Results 1 to 5 of 5
  1. #1
    jlindquist23 is offline Advanced Beginner
    Windows 7 64bit Access 2016
    Join Date
    Jan 2019
    Posts
    47

    Message Box works on click but not on change

    This code works on a click and not a change and I can't figure out why?


    The data is in a subform inside the main form. Diff1 is a General Number variable in the subform.


    Private Sub Diff1_Change()
    If (Me.Diff1.Value > 4 And Forms![HTRecord]![EmpID_2] = "") Then
    MsgBox "Hello " & Forms![HTRecord]![EmpID] & "," & Chr(13) & Chr(10) & "Rockwell range on this part is greater than 4 points! Segregate rack, complete DMA and move parts to QUALITY HOLD area." & Chr(13) & Chr(10) & Chr(13) & Chr(10) & "DO NOT RE-RUN PARTS!", vbCritical, "4 Point Spread Max"
    ElseIf (Me.Diff1.Value > 4 And Forms![HTRecord]![EmpID_2] <> "") Then
    MsgBox "Hello " & Forms![HTRecord]![EmpID] & Chr(13) & Chr(10) & Forms![HTRecord]![EmpID_2] & Chr(13) & Chr(10) & Chr(13) & Chr(10) & "Rockwell range on this part is greater than 4 points! Segregate rack, complete DMA and move parts to QUALITY HOLD area." & Chr(13) & Chr(10) & Chr(13) & Chr(10) & "DO NOT RE-RUN PARTS!", vbCritical, "4 Point Spread Max"
    End If
    End Sub


    Private Sub Diff1_Click()
    If (Me.Diff1.Value > 4 And Forms![HTRecord]![EmpID_2] = "") Then
    MsgBox "Hello " & Forms![HTRecord]![EmpID] & "," & Chr(13) & Chr(10) & "Rockwell range on this part is greater than 4 points! Segregate rack, complete DMA and move parts to QUALITY HOLD area." & Chr(13) & Chr(10) & Chr(13) & Chr(10) & "DO NOT RE-RUN PARTS!", vbCritical, "4 Point Spread Max"
    ElseIf (Me.Diff1.Value > 4 And Forms![HTRecord]![EmpID_2] <> "") Then
    MsgBox "Hello " & Forms![HTRecord]![EmpID] & Chr(13) & Chr(10) & Forms![HTRecord]![EmpID_2] & Chr(13) & Chr(10) & Chr(13) & Chr(10) & "Rockwell range on this part is greater than 4 points! Segregate rack, complete DMA and move parts to QUALITY HOLD area." & Chr(13) & Chr(10) & Chr(13) & Chr(10) & "DO NOT RE-RUN PARTS!", vbCritical, "4 Point Spread Max"
    End If
    End Sub


  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    The change event fires with every keystroke, so normally you want the after update event. If you do want the change event, you have to use the .Text property of the control. The .Value property won't be updated while the user is still typing.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    jlindquist23 is offline Advanced Beginner
    Windows 7 64bit Access 2016
    Join Date
    Jan 2019
    Posts
    47
    I didn't realize that.
    I made that change, but message box still won't go.

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,574
    Perhaps show your latest code?
    This time within code tags?

    Much easier to read then.
    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

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Sorry, I'm not getting email notifications for some reason. Set a breakpoint and examine the values in the controls being tested. Note that Null and "" are different things, and you're only testing for one of them. This tests for both:

    Nz(Forms![HTRecord]![EmpID_2], "") <> ""
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Button On click change VBA code
    By sparky23 in forum Programming
    Replies: 1
    Last Post: 08-24-2019, 03:40 PM
  2. Combobox change width on click
    By bilalo in forum Forms
    Replies: 7
    Last Post: 07-20-2019, 01:33 AM
  3. Change right click in report
    By Mehvan in forum Reports
    Replies: 4
    Last Post: 07-09-2018, 06:20 AM
  4. Search Form Results Change When I Click On Them
    By DaneTrain24 in forum Forms
    Replies: 5
    Last Post: 02-04-2016, 05:03 PM
  5. Replies: 3
    Last Post: 10-18-2009, 09: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