Results 1 to 6 of 6
  1. #1
    NISMOJim is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2010
    Posts
    273

    Glitch?

    Users fill out a form, then click the Submit button. When clicked, the VBA sends me an email saying who filled out the form, and the Details textbox. A messagebox pops up letting the user know that the form was submitted, then closes the form. Most of the time, it works perfectly. But sometimes, with a few different users, I get the email, they get the messagebox, then the form closes, but is not saved to the table. Could this be just an occasional glitch?

  2. #2
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Posting all the code for this operation might provide some clue. If this is always for the same user(s) that could be important too. I suspect the issue is in the button click or perhaps you have turned off warnings just before and you're not being advised of some failure.
    Please use code tags (# on posting toolbar) when posting code.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    NISMOJim is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2010
    Posts
    273
    There are 2 or 3 users that it seems to happen to more frequently, but it also works correctly for them just as often. Here is the code...

    Code:
     If Len(Me.txtWODesc) > 5 Then 
       Me.txtEmpName = Me.txtLUEmpName
       Me.txtReqDate = Me.txtDate
       Me.txtWODeptNo = Me.txtEmpDeptNo
     
      '--------------------------------------------------
    
    
       'Compose email to Technician Supervisor
        Dim MsgBody As String
        Dim MsgDetail As String
        Dim appOutLook As Outlook.Application
        Dim MailOutLook As Outlook.MailItem
        Dim MsgLink As String
        Dim MsgTo As String
        Dim MsgRemind As String
      
        MsgDetail = Me.txtWODesc
        MsgLink = "S:\3500-AZ Office Operations\Test Operations\Technician Work Orders/Technician Work Orders.accdb"
        MsgBody = "A new work order has been submitted by " & Me.txtLUEmpName & "." & "<br>" & "Click <a href='" & MsgLink & "'> Here </a>" & " to open the database, or go to S:\ Operations\Technician Work Orders/Technician Work Orders.accdb." & "<br>" & "Work Order Details:  " & MsgDetail & "<br>" & "Thank you."
        MsgBody2 = "Reminder: You submitted a work order on " & Me.txtDate & " with the following details;" & "<br>" & Me.txtWODesc
        MsgRemind = Me.txtEmpEMail
        
          
       Set appOutLook = CreateObject("Outlook.Application")
       Set MailOutLook = appOutLook.CreateItem(olMailItem)
       With MailOutLook
           .BodyFormat = olFormatRichText
           .To = MsgTo '"VoC@nrd.com; HaR@nis.com; JaO@Nis.com"
     
    
    
           .Subject = "New Technician Work Order"
           .HTMLBody = MsgBody
     
           .Send
        Set appOutLook = Nothing
        Set MailOutLook = Nothing
       End With
     
      '--------------------------------------------------
       'Compose reminder email to requestor
       Set appOutLook = CreateObject("Outlook.Application")
       Set MailOutLook = appOutLook.CreateItem(olMailItem)
       With MailOutLook
           .BodyFormat = olFormatRichText
           .To = MsgRemind
           .Subject = "Reminder:  Work Order submitted - " & Me.txtDate
           .HTMLBody = MsgBody2
       
           .Send
       End With
     
     
        MsgBox "Work Order Submitted", vbOKOnly
     
       DoCmd.Close
       
     Else
       MsgBox "Please enter a detailed description of work to be performed", vbOKOnly
       Me.txtWODesc.SetFocus
       Exit Sub
     End If
    
    
     Exit Sub

  4. #4
    Minty is online now VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,001
    I would make your code force a save to the record and only explicitly close the form you are on;

    Instead of
    Code:
       MsgBox "Work Order Submitted", vbOKOnly
     
       DoCmd.Close
    I would use

    Code:
    MsgBox "Work Order Submitted", vbOKOnly
    
    If Me.Dirty Then Me.Dirty = False   ' Force the record to save
    
    DoCmd.Close acForm, Me.Form.Name
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  5. #5
    moke123's Avatar
    moke123 is online now Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,643
    Is there any other code in the form module, like in the before update event?
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  6. #6
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Agree with both. The vast majority of the posted code is about the email, which isn't the problem. What comes before and is related to what the user is doing is what's important. However, the suggested mod might fix the issue because it looks like a record is being modified but there's no evidence of the changes being committed. Some users might be doing something differently all or just sometimes which causes the record to be saved by chance.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Running Total Glitch ?
    By Freddie81 in forum Queries
    Replies: 9
    Last Post: 05-18-2018, 08:46 AM
  2. Glitch - Need Help
    By Squirrel1804 in forum Access
    Replies: 5
    Last Post: 04-04-2016, 09:32 AM
  3. Enter a Parameter Value glitch?
    By astrocamstar in forum Access
    Replies: 8
    Last Post: 10-05-2014, 01:04 PM
  4. VBA Glitch using Dates
    By stryker1080 in forum Programming
    Replies: 4
    Last Post: 10-05-2009, 04:57 PM
  5. Page numbering glitch
    By kfinpgh in forum Reports
    Replies: 3
    Last Post: 08-17-2006, 08:23 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