Results 1 to 2 of 2
  1. #1
    GraemeG is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Feb 2011
    Posts
    152

    Export single record from a form to PDF

    Hello.

    I am having trouble exporting single records from a form to pdf.
    I have the following code so far. but it gives:

    Run time error 3464
    Data type mismatch in criteria expression.

    Debug highlights:
    Me.RecordSource = "Select * From Propertyextract Where [propref] = " & _
    ![propref]



    Any help appreciated.

    Code:
    Private Sub cmdExportPDF_Click()
     Dim MyDB As DAO.Database
        Dim MyRS As DAO.Recordset
        Dim strSQL As String
     
     
        strSQL = "Select Propertyextract.[propref] From Propertyextract;"
     
        Set MyDB = CurrentDb
        Set MyRS = MyDB.OpenRecordset(strSQL, dbOpenForwardOnly)
     
        With MyRS
          Do While Not MyRS.EOF
            Me.RecordSource = "Select * From Propertyextract Where [propref] = " & _
                               ![propref]
            DoCmd.OutputTo acOutputForm, "FrmPropertyAttributes", acFormatPDF, "" & ![propref] & ".pdf"
             .MoveNext
          Loop
        End With
     
     
        MyRS.Close
        Set MyRS = Nothing
    End Sub

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    What is the data type of propref? If text, the value needs to be surrounded by single quotes.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Single Record Update Query from a Form
    By Steven.Allman in forum Access
    Replies: 0
    Last Post: 03-30-2011, 09:34 AM
  2. Print Single Record
    By stattech in forum Reports
    Replies: 5
    Last Post: 10-05-2010, 03:38 AM
  3. Replies: 0
    Last Post: 05-13-2010, 05:18 AM
  4. Export single records to new Word Document
    By karmaimages in forum Import/Export Data
    Replies: 0
    Last Post: 11-19-2009, 03:37 PM
  5. Adding a single record
    By kfoyil in forum Forms
    Replies: 2
    Last Post: 11-22-2006, 09:12 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums