Sensibilium
Programmer
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.
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
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