Export from MS access to PDF with set variables from a the opened form

Good to hear!

What was the slight tweak?
 
Defeats the whole purpose.
 
Ok, I see the problem. There's a typo:
Code:
Public Function StripInvalidChars(TheString As String) As String
    Dim varChars As Variant
    Dim x        As Integer
    
    Const INVALID_NAME_CHARS As String = "\ / : * ? "" < > |"
    
    varChars = Split(INVALID_NAME_CHARS, " ")
    
    For x = LBound(varChars) To UBound(varChars)
        TheString = Replace(TheString, varChars(x), "")
    Next
    
    [COLOR="Blue"]StripInvalidChars[/COLOR] = TheString
End Function
It read "StripInvalid" instead of "StripInvalidChars". Now it should work as expected.
 
An additional problem has risen, Everything works the form is saved to the correct location with the correct title however. the PDF shows "all forms/record"

How do I isolate it to only show the opened form?
 
Ok, I see the problem. There's a typo:
Code:
Public Function StripInvalidChars(TheString As String) As String
    Dim varChars As Variant
    Dim x        As Integer
 
    Const INVALID_NAME_CHARS As String = "\ / : * ? "" < > |"
 
    varChars = Split(INVALID_NAME_CHARS, " ")
 
    For x = LBound(varChars) To UBound(varChars)
        TheString = Replace(TheString, varChars(x), "")
    Next
 
    [COLOR=blue]StripInvalidChars[/COLOR] = TheString
End Function
It read "StripInvalid" instead of "StripInvalidChars". Now it should work as expected.


That has fixed that problem.
 
Is the button on the same form from which the pdf is generated?
 
Is the button on the same form from which the pdf is generated?

Yes it is, In my form along with all the other combo boxes, memo boxes etc there are 3 email buttons with its own macro, 1 create new form button, save form button, close form button and the last one being Save to PDF button.
 
Replace the blue bits with the correct name of the field that uniquely identifies each record:
Code:
Private Sub Save_to_PDF_Click()
    Dim myPath      As String
    Dim strBookmark As String
    
    With Me
        myPath = "Z:\(P) Maintenance\Hamilton Jet Planned Maintenance\Jobs\"
        myPath = myPath & Format(.[Closed date], "dd_mm_yy")
        myPath = myPath & "_" & StripInvalidChars(.[Effected area] & "_" & .[Asset] & "_" & .[Title]) & ".PDF"
        
        strBookmark = .Bookmark
        .Filter = "[[COLOR="Blue"]ID[/COLOR]] = " & .[[COLOR="blue"]ID[/COLOR]]
        .FilterOn = True
        
        DoCmd.OutputTo acOutputForm, .Name, acFormatPDF, myPath, False
        
        .Filter = vbNullString
        .FilterOn = False
        .Bookmark = strBookmark
    End With
End Sub
 
That is exactly what I needed again I can only thank you for all your help. :D
 

Users who are viewing this thread

Back
Top Bottom