Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access 2K App Break To Code Window When Starting Common Dialog Control

Status
Not open for further replies.

Sensibilium

Programmer
Apr 6, 2000
310
0
0
GB
Hi,

I've been having this trouble on my clients for quite a while now, and it is quite frustrating, as no matter what I do seems to fix it.

The situation is thus: The client hits the Export button in my app, and as soon as the code gets to setting the basic options for the common dialog control, it breaks and throws the user into the code window.

The code at which it stops is highlighted in the below Subroutine.

Code:
Private Sub cmdExport_Click()
On Error GoTo Error_cmdExport_Click
    Dim dbs As Database
    Dim rstNewProducts As Recordset
    Dim dAverageCost As Double
    Dim intCounter As Integer
    Dim sEmail As String
    
    cmdExit.SetFocus
    cmdExport.Enabled = False
    Me.Visible = False
    [b]dlgCommon.Filter = "CSV Files (*.csv)|*.csv"[/b]
    dlgCommon.Filename = "NewProds"
    dlgCommon.InitDir = "Y:\Files For Importing\"
    dlgCommon.CancelError = True
    dlgCommon.ShowSave
    
    Set dbs = CurrentDb()
    Set rstNewProducts = dbs.OpenRecordset("qryProductReadyForUpload")
    Open dlgCommon.Filename For Output As #1
    With rstNewProducts
        .MoveLast
        .MoveFirst 'Populate
        Call SysCmd(acSysCmdInitMeter, "Exporting Products", .RecordCount)
        intCounter = 0
        Do Until .EOF
            .Edit
            Print #1, !ItemCode; ","; !OurDescription; ","; "T1"; ","; !SellingPrice; ","; dAverageCost; ","; "EACH"; _
                ","; !Location; ","; "4000"; ","; !DesignID; ",,"; !SupplierRef; ","; !SupplierCode & ""; _
                ",,"; !ItemType; ","; !ArticleNumber; ","; !Weight; "," ' Separate strings with commas.
            !ReadyForUpload = False
            !Complete = True
            .Update
            intCounter = intCounter + 1
            Call SysCmd(acSysCmdUpdateMeter, intCounter)
            .MoveNext
        Loop
    End With
    MsgBox "Importable file '" & dlgCommon.Filename & "' created successfully.", vbOKOnly, "Export Successful"
    rstNewProducts.Close


Exit_cmdExport_Click:
    Call SysCmd(acSysCmdRemoveMeter)
    Close #1
    cmdExport.Enabled = True
    Me.Visible = True
    DoCmd.Close
    Exit Sub
    
Error_cmdExport_Click:
    If Err.NUMBER = 32755 Then 'Cancel clicked in Save As... dialog
        MsgBox "Products not exported.", , "File Save Cancelled..."
        Resume Exit_cmdExport_Click
    Else
        MsgBox "Err No: " & Err.NUMBER & ". Description: " & Err.Description & " - In Sub cmdExport_Click, frmExportNewProducts"
        Resume Exit_cmdExport_Click
    End If
End Sub

When the user hits the continue button, the code carries on without problem.

VBA Break Options are set to Break On All Unhandled Errors.

All clients have correct References installed and working.

Any help would be greatly appreciated.

(Perhaps I need to take out Code Librarian from VBA References? I'm just grabbing at straws here).

Ahdkaw
 
Please note, the client application has been created with the Package & Deployment Wizard. So it shouldn't have the Code Librarian packaged with it anyway, should it?

Ahdkaw
 
How and where is dlgCommon declared and instantiated ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Ah yes, please forgive my foolishness.

It's instantiated on the form, there is no other reference to it in the underlying code, except where already noted.

Name: dlgCommon
OLE Class: CommonDialog
Verb: 0
Class: MSComDlg.CommonDialog.1

Ahdkaw
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top