Results 1 to 5 of 5
  1. #1
    3 Star Lounger
    Join Date
    Sep 2002
    Posts
    294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Wierd Error message (2000)

    Previously Hans kindly supplied me with the required line of code to output a report into a .Rtf file, i added a button to the code, added a few bits on the end to add the date and tested it with a couple of documents and all appeared well.


    The code is thus :-

    <font color=blue>Private Sub Command43_Click()
    ' ------------------------------------------------------------------------ transfer to word ------------------------------------------------------
    On Error GoTo errh

    Dim cArea As String, cDdoc As String

    cArea = [Forms]![FTRAINUP17]![cdept]
    cDoc = [Forms]![FTRAINUP17]![cmddoc]

    DoCmd.OutputTo acOutputReport, "TEAM SIGNOFF3", acFormatRTF, "C:" & cArea & "-" & cDoc & "-" & date$ & ".rtf"

    Beep
    Beep
    Beep
    Beep

    Exit Sub
    errh:
    CentralError (ERR)
    Select Case UN
    Case "R"
    Resume
    Case "C"
    Resume Next
    End Select
    End Sub</font color=blue>


    cArea and CDoc are basically combo boxes.

    What is now happening in some cases is when the button is clicked, the error message shown below appears. it suggests that the file is in use, but.. there is no file to be in use, in all cases print previewing the document shows up fine.

    So i can print preview the report, but i cannot send it to .rtf file. <img src=/S/disappointed.gif border=0 alt=disappointed width=15 height=15>
    Attached Images Attached Images

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Wierd Error message (2000)

    Steve,

    The error message mentions that a file is open, this is probably the .rtf file. If you try this code repeatedly, an .rtf file of the specified name "C:" & cArea & "-" & cDoc & "-" & date$ & ".rtf" probably exists already. You can test this by temporarily commenting out the On Error GoTo errh line; the offending code will be highlighted when you get the error message and select Debug.

    You can try to delete the .rtf file if it already exists:

    If Dir("C:" & cArea & "-" & cDoc & "-" & date$ & ".rtf") <> "" Then
    Kill "C:" & cArea & "-" & cDoc & "-" & date$ & ".rtf"
    End If

    but if a user has the .rtf file open in Word when you try this, you'll get an error message because you can't delete an open document.

  3. #3
    3 Star Lounger
    Join Date
    Sep 2002
    Posts
    294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Wierd Error message (2000)

    Thats the weird thing about this hans.

    1) Word isn't even open when it gives this message..

    2) In the folder where it stores the files, there are no .rtf files. and no open filenames


    I will try commenting out the error part to see if i can learn anything new !


    Update: removing the on error part, produces the error as shown below.
    Attached Images Attached Images

  4. #4
    3 Star Lounger
    Join Date
    Sep 2002
    Posts
    294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Wierd Error message (2000)

    Further investigation revealed that the outputTo command doesn't allow foward slashes "/" , and so the error message is created.
    Certain characters are not allowed. as shows in this Microsoft Article.

    So i just have to perform some modification to the filename.



    <img src=/S/clapping.gif border=0 alt=clapping width=19 height=23>

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Wierd Error message (2000)

    I'm glad you found the cause. You could use Format(Date$, "yyyymmdd") or Format(Date$, "dd-mm-yyyy") or something like that, where Date$ is the date you want to include in the file name.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •