Results 1 to 3 of 3
  1. #1
    Star Lounger
    Join Date
    Jul 2003
    Posts
    62
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Need help with code - Saving .snp files and emails (2k/2k2)

    <img src=/S/jollyroger.gif border=0 alt=jollyroger width=29 height=18>

    At my work we have a folder that can convert .snp files to .pdf's in a matter of seconds. You copy a report in and about 5 to 15 seconds later, you have your pdf, the original gets destroyed. I want to out put one of several reports to this folder, wait for it to translate, attach it to an email once completed, and send it. I have code to creat the email part of it and have it working good, I just need a little help with the moving, the looking and the waiting. Here is what I have. On a form:

    Private Sub Command142_Click()
    EmailReport "FCR", "rptFCR", Me.Job_, Me.[CustPart#]
    End Sub

    in a module ...

    Option Compare Database

    Public Function EmailReport(strType, strReview, strJob, strPart As String)
    Dim doubStart As Double
    Dim intCount As Integer

    doubStart = Timer
    intCount = 1

    DoCmd.Hourglass True

    DoCmd.OutputTo acOutputReport, strReview, acFormatSNP, _
    "Q:Convert" & strType & " " & strJob & " " & strDate & _
    " Part# " & strPart & ".snp"

    EmailReport_Wait:
    Do While Timer < doubStart + 5 ' 5 SECONDS at a time FOR STARTERS
    DoEvents ' Yield to O.S.
    Loop

    If intCount = 10 Then
    MsgBox "Error Converting file to .pdf format. Try again or see the" _
    & " database administrator."
    GoTo EmailReport_Exit
    Else
    If FileExistsDIR("Q:Convert" & strType & " " & strJob & " " & strDate & _
    " Part# " & strPart & ".pdf") = False Then
    intCount = intCount + 1
    GoTo EmailReport_Wait
    Else
    DoCmd.Beep
    'create email, attach file here
    End If
    End If

    DoCmd.Hourglass False

    EmailReport_Exit:
    Exit Sub

    End Function
    Function FileExistsDIR(sFile As String) As Boolean

    FileExistsDIR = True
    If Dir$(sFile) = vbNullString Then FileExistsDIR = False

    End Function


    I am new to VB, and am not sure if this a good way to do this, but it isin't working. I get an error that says The report snap shot was not created becase I don't have enough free disk space for temperary work files. Hoping someone can help me muddle through this!

    Thanks

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

    Re: Need help with code - Saving .snp files and emails (2k/2k2)

    In general, when an error occurs in VBA code without error handling, you'll be presented with an error message and a choice of End, Debug and Help. If you select Debug, you will be taken to the Visual Basic Editor and the offending instruction will be highlighted. You can use this to try to find out what causes the error, and if you ask about it in the Lounge, it helps to mention in which instruction the error occurs.

    Since the error message you get states that the snapshot was not created, my guess is that the error occurs in DoCmd.OutputTo, and that it has to do with the file name. You try to concatenate the date into the file name. Your default date format is probably mm/dd/yy, and that is the problem. A file name can not contain a slash /. To work around this, apply a format without slashes to the date. It is not clear where strDate comes from in your code, but if it is the current date, try something like

    strDate = Format(Date, "mmddyy")

    or

    strDate = Format(Date, "mm-dd-yy")

  3. #3
    Star Lounger
    Join Date
    Jul 2003
    Posts
    62
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Need help with code - Saving .snp files and emails (2k/2k2)

    Hans,

    Setting the format was key. In fact it alerted me to some other potential pitfalls in my naming scheme. Turn's out the error was due to inadaquate permissions to the folder. Thanks for your help ... again!

Posting Permissions

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