Form lost focus after Word Merge issue

mattkorguk

Registered User.
Local time
Today, 21:17
Joined
Jun 26, 2007
Messages
301
Hi,
I'm sure we've done this many times before, but it seems to not liking it this time.
We're exporting an Excel list and opening a Word mail merge document, this bit works fine.
When the user then closes Word we have a little dialogue message box to confirm the printing was all ok, if they click 'Yes' then we run an update query to mark the clients stating the letter has been sent.
This is where we have the issue of the form then not receiving Focus. You end up with a little grey box where the message box used to be!
The only way to try and get it back is to minimise Access, then Restore, and then some of the menu items become available and you can go back to the Switchboard and then select the original form again.
Code:
Private Sub cmdExport_Click()
    Dim oApp As Object
'    Dim LetterName As String
    
    On Error GoTo Export_Error
    
    DoCmd.SetWarnings False
    
    DoCmd.Echo False, "Cleaning..............."
    Kill "c:\ll-export\ll-merge.xls"
No_Delete:
    DoCmd.Echo False, "Exporting Customer Details..........."
    DoCmd.OpenQuery "qryExport-Chasers"
    DoCmd.Echo False, "Preparing Spreadsheet........."
    DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "LL-Merge", "c:\ll-export\ll-merge.xls"
'    DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "qryLL-TelNo", "c:\ll-export\ll-TelNo.xls"
'    DoCmd.OpenForm "frmChasers-History"

    
'    LetterName = MLetterName
    DoCmd.Echo False, "Opening Letter............"
    Set oApp = GetObject("c:\ll-export\Chaser-Live.doc")
    oApp.Application.Visible = True

If MsgBox("Collect Printing  and  Confirm Printing OK.", vbYesNo, "Chaser Letter Printing") = vbYes Then
    DoCmd.OpenQuery "qryUpdate-Chasers"
    Me.Requery
Else
    Forms![frmDetail-Master].SetFocus
    Forms![frmDetail-Master].Repaint
End If
    DoCmd.SetWarnings True
 
 
Exit_Export:
    Exit Sub
    
Export_Error:
    If Err.Number = "53" Then
        Resume No_Delete
    Else
        MsgBox "Error No: " & Err.Number & ". " & Err.Description, vbOKOnly, "Export Error"
        Resume Exit_Export
    End If
End Sub
Any suggestions appreciated.
 

Users who are viewing this thread

Back
Top Bottom