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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Commondialog Double Cancel Error 1

Status
Not open for further replies.

YoshiCD

Programmer
Feb 24, 2001
96
ES
Hi All,

I have a problem with the CDI Save As box.
I have inserted an errorhandler to capture the Cancel button, telling the user they MUST enter a filename and returning (by GoTo) to above the part (in code) where the Dialog box is shown.
Problem is, if the user presses Cancel for a second time, the errorhandler no longer captures the error, instead giving me the Runtime error that Cancel was Selected.
WHERE AM I GOING WRONG?????

Heres the code...

[tt]
'Initialise Error Handler
On Error GoTo ErrorHandler

---More Code---

ReSave:

With cdiMain
.DialogTitle = "Save New Insomniac CD"
.InitDir = App.Path & "\Library"
.Filter = "Insomniac Files|*.inm"
.Filename = UserFile 'USERFILE VARIABLE DEFAULT
.CancelError = True
.ShowSave

If Trim(.Filename) <> &quot;&quot; Then
TrackFilename = .Filename
txtDetails(4).Text = .Filename
CDFilename = Mid(.Filename, 1, Len(.Filename) - 4) & &quot;.cdi&quot;
Filenum = FreeFile

'Create Trackfile
Open TrackFilename For Random As Filenum Len = Len(Trax)
Close Filenum

Filenum = FreeFile

'Create CD File
Open CDFilename For Random As Filenum Len = Len(CD)
Close Filenum

'Create MasterFile
Open App.Path & &quot;\insomniac.inm&quot; For Random As Filenum Len = Len(Files)
Files.CDFile = Trim(CDFilename)
Files.Trackfile = Trim(TrackFilename)

Put Filenum, 1, Files
Close Filenum

Else
MsgBox &quot;Invalid Filename&quot;
End If
End With

---More Code--

Exit Sub


ErrorHandler:
If Err.Number = cdlCancel Then
MsgBox &quot;You Must Enter a New Filename&quot;, vbExclamation + vbOKOnly, &quot;Save Error&quot;
GoTo ReSave
Else
msgString = &quot;An Error Has Occured While Saving The File, If this occurs again, Contact Technical Support&quot; + vbLf + &quot;Error Number : &quot; & Err.Number & &quot; (&quot; & Err.Description & &quot;)&quot;
MsgBox msgString, vbOKOnly + vbExclamation, &quot;Save Error&quot;
Resume Next
End If
[/tt]

Sorry for the untidiness


Thanks in Advance.



[yinyang] ¥oshi [yinyang]

-------------------------
&quot;There is No Spoon..&quot;
-------------------------
Programming Outsource:
 
You could set the cdiMain.CancelError = False and instead test if the cdiMain.filename = &quot;&quot; if so Goto ReSave:
 
CClint,

Thanks a million buddy, worked a dream!

Regards,


[yinyang] ¥oshi [yinyang]

-------------------------
&quot;There is No Spoon..&quot;
-------------------------
Programming Outsource:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top