Page 1 of 2 12 LastLast
Results 1 to 15 of 27
  1. #1
    82280zx's Avatar
    82280zx is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Jan 2014
    Posts
    82

    Messagebox popping up twice?

    I'm setting up one of my forms to make sure the user enters data into the fields and generates a error in a message box if the value is null.

    What I have so far is this



    If IsNull(Me.txtModel) Then
    MsgBox "Please enter the Model Information", vbCritical, "Canceling Update"
    Me.txtModel.SetFocus
    Cancel = True
    End If

    So when the user go's to save the new asset if one of the fields that I require (for reports and queries to work correctly) is left blank, warn the user that it was left blank and don't allow the user to continue until something is entered in, the code works but I receive two pop up box's and I should only be seeing one. I'm putting this in BeforeUpdate as well.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    What event(s) are used? If there is MsgBox code in multiple events and those events run then there will be multiple popups.
    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
    atuhacek is offline New
    Windows 8 Access 2010 64bit
    Join Date
    Jun 2014
    Location
    Michigan
    Posts
    61
    What are you using to call your function? Before update for your form or a control.

  4. #4
    82280zx's Avatar
    82280zx is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Jan 2014
    Posts
    82
    Quote Originally Posted by atuhacek View Post
    What are you using to call your function? Before update for your form or a control.
    BeforeUpdate on my Form.

  5. #5
    82280zx's Avatar
    82280zx is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Jan 2014
    Posts
    82
    Quote Originally Posted by June7 View Post
    What event(s) are used? If there is MsgBox code in multiple events and those events run then there will be multiple popups.
    There are multiple events being used on the form but I only have the MsgBox in the BeforeUpdate event.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    The popups are identical? Would have to review code. If you want to provide db, follow instructions at bottom of my post.
    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.

  7. #7
    atuhacek is offline New
    Windows 8 Access 2010 64bit
    Join Date
    Jun 2014
    Location
    Michigan
    Posts
    61
    use the after update call. the before update call happens before anything else. it wont matter if the data is entered or not it is going to make the call before the info has had a chance to be entered at all.

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    I disagree with using AfterUpdate. The record needs to be validated before committing to table and while the record still has focus.
    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
    atuhacek is offline New
    Windows 8 Access 2010 64bit
    Join Date
    Jun 2014
    Location
    Michigan
    Posts
    61
    You might be right but before is before the record has a chance. i normally run a check on after update. Access doesn't "save" or "commit" is commits on entry so using the after update is like using your save or commit. It has worked for me in the past. Put an msg in a before update event. it fires on first action.

    Correction! The form before update won't. I was thinking of the control level.

  10. #10
    82280zx's Avatar
    82280zx is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Jan 2014
    Posts
    82
    Yea I see two of the same pop up's, not sure why. I've got to clear out some stuff then I'll upload my db file, it's been a while since I've had it reviewed I'm sure it will have lots of fun stuff I'm going to need to fix .

  11. #11
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    You probably need to post the entire code for your Form_BeforeUpdate event.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  12. #12
    82280zx's Avatar
    82280zx is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Jan 2014
    Posts
    82
    Quote Originally Posted by June7 View Post
    The popups are identical? Would have to review code. If you want to provide db, follow instructions at bottom of my post.
    The file is greater than two meg so I had to put it on my box account but heres my blank db https://app.box.com/s/gxwqtgd4kcuf11fplg30 I hope it's not to scary, I'm still learning.

    Thanks!

  13. #13
    82280zx's Avatar
    82280zx is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Jan 2014
    Posts
    82
    Quote Originally Posted by 82280zx View Post
    The file is greater than two meg so I had to put it on my box account but heres my blank db https://app.box.com/s/gxwqtgd4kcuf11fplg30 I hope it's not to scary, I'm still learning.

    Thanks!
    Also the code in question is under Manage Assets Form, in the Form_BeforeUpdate event but I removed the code because of the problem I was having in the one I uploaded, I thought I had left it in.

  14. #14
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    So you're saying there isn't any code to analyze? I tried entering record on that form and get error that record is required in Agency. There are no records to test with. Provide db with code and dummy records and instructions on how to recreate the issue. Try zipping the db and see if that is small enough - 2MB zip allowed.
    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.

  15. #15
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    It would really help if you would post your entire code for your Form_BeforeUpdate event, as I requested earlier, as not everyone can run an Access 2013 file.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. MessageBox if the report is Empty
    By annyK in forum Reports
    Replies: 2
    Last Post: 10-14-2013, 03:53 AM
  2. On Change or Before Update? MessageBox
    By burrina in forum Forms
    Replies: 6
    Last Post: 01-05-2013, 12:09 PM
  3. messagebox help :D
    By imintrouble in forum Forms
    Replies: 2
    Last Post: 10-20-2011, 01:50 PM
  4. MsgBox in VBA Editor not popping up
    By KrisDdb in forum Access
    Replies: 2
    Last Post: 09-16-2011, 01:58 PM
  5. Make a messagebox
    By carstenhdk in forum Queries
    Replies: 7
    Last Post: 05-18-2010, 06:18 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