Page 4 of 7 FirstFirst 1234567 LastLast
Results 46 to 60 of 100
  1. #46
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,921
    See example code in post 41.



    And need to include Data_modulo in the report filter criteria parameter along with Cognome.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  2. #47
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    oops, this thread is so long I forgot what the first post was....

  3. #48
    ingarchsf is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2014
    Posts
    50
    Quote Originally Posted by ssanfu View Post
    oops, this thread is so long I forgot what the first post was....
    Don't worry!! ahaha

    Quote Originally Posted by June7 View Post
    See example code in post 41.

    And need to include Data_modulo in the report filter criteria parameter along with Cognome.
    ok, I've changed that line and added that parameter.. not the error is still 3061 but needed parameters are 4 :P

    what do I have to put into [some field name] and controlname? which one?

  4. #49
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,921
    You need to learn how to construct strings by concatenating literal text with variables.

    You have done some with:

    DoCmd.OpenReport strRptName, acViewPreview, , "[Cognome]='" & ![Cognome] & "'"

    Now expand on that:

    DoCmd.OpenReport strRptName, acViewPreview, , "[Cognome]='" & ![Cognome] & "' AND [Data_modulo]=#" & !Data_modulo & "#"


    And also apply filter to the recordset SQL instead of using dynamic parameters in query object.

    Did you remove dynamic parameters from the query object?

    Example for text, date, number field:

    strSQL = "Select Selezione_corso_2014.[Cognome], Selezione_corso_2014.[Data_modulo] From Selezione_corso_2014 WHERE [a text field name]='" & Me.textinputcontrol & "' AND [a date field name]=#" & Me.dateinputcontrol & "# AND [a number field name]=" & Me.numberinputcontrol & ";"

    Construct as appropriate for your filter requirements and use the names of your fields and controls.


    If you are using international data structure, that will cause another set of issues when filtering with date values. Review: http://allenbrowne.com/ser-36.html
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #50
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    @ingarchsf,
    I must say that you have helped me by making me work on the code to export reports in PDF.


    Maybe an example will help you. So attached is the dB I created to test the export to PDF.
    It is very basic.....

  6. #51
    ingarchsf is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2014
    Posts
    50
    Quote Originally Posted by June7 View Post
    You need to learn how to construct strings by concatenating literal text with variables.

    You have done some with:

    DoCmd.OpenReport strRptName, acViewPreview, , "[Cognome]='" & ![Cognome] & "'"

    Now expand on that:

    DoCmd.OpenReport strRptName, acViewPreview, , "[Cognome]='" & ![Cognome] & "' AND [Data_modulo]=#" & !Data_modulo & "#"


    And also apply filter to the recordset SQL instead of using dynamic parameters in query object.

    Did you remove dynamic parameters from the query object?

    Example for text, date, number field:

    strSQL = "Select Selezione_corso_2014.[Cognome], Selezione_corso_2014.[Data_modulo] From Selezione_corso_2014 WHERE [a text field name]='" & Me.textinputcontrol & "' AND [a date field name]=#" & Me.dateinputcontrol & "# AND [a number field name]=" & Me.numberinputcontrol & ";"

    Construct as appropriate for your filter requirements and use the names of your fields and controls.


    If you are using international data structure, that will cause another set of issues when filtering with date values. Review: http://allenbrowne.com/ser-36.html
    I've tried, but it says that there is an error in [datefieldname]..

    Quote Originally Posted by ssanfu View Post
    @ingarchsf,
    I must say that you have helped me by making me work on the code to export reports in PDF.


    Maybe an example will help you. So attached is the dB I created to test the export to PDF.
    It is very basic.....
    I have helped? ahah.. honored!!
    I've tried your DB, and it's exactly what I'm looking for!!

    I've also tried to put the code inside my DB.. but there's somehing that I don't understand: I've seen that in some cases, the date has month and day inverted!! Or.. some PDF has no data.. even if they exist as "date".

    There is another thing that I need to use: in the Form you have used only a text box, and I need to use also 2 number box (N_corso and N_modulo) which have 2 parameters (qncorso1 and qnmodulo1), which are used to select records inside Selezione_corso_2014.

    I0ve tried to add a "WHERE" condition, using what June7 has posted, but I'm not able -.-°
    Last edited by ingarchsf; 08-29-2014 at 02:44 PM. Reason: partially solved

  7. #52
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,921
    What is error message? Instead of [datefieldname] use your actual field name.

    Did you review Allen's link about international date?

    Post your attempted code or provide your database.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  8. #53
    ingarchsf is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2014
    Posts
    50
    Ok, now dates are ok.. but some PDF has no data.. even if they exist as "date".

    UPDATE: no.. some dates are ok, some other are inverted O_O..

  9. #54
    ingarchsf is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2014
    Posts
    50
    Quote Originally Posted by June7 View Post
    What is error message? Instead of [datefieldname] use your actual field name.

    Did you review Allen's link about international date?

    Post your attempted code or provide your database.
    there's no error.. the cursor stops on a parameter..

  10. #55
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,921
    Don't know what that means. Not something I can analyse.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  11. #56
    ingarchsf is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2014
    Posts
    50
    about dates: I've tried to write into "Format" option (in the table) the format gg/mm/aaaa, the same into the option "Format" of the query that takes from the table.. but the result is the same..

    some dates are ok, i.e. 20/05/2014 (20th may 2014), but others are not, i.e. 06/05/2014 (6th may 2014) which is turned to 05/06/2014 (5th june 2014)..


    example1: in the table, both exist, but.. the PDFdocument that belongs to 06/05/2014 is written 20140605 and the PDFdocument that belongs to 05/06/2014 is written 20140506.. exactly the opposite!!
    example2: in the table, only 03/06/2014 (3rd june 2014) exists.. the PDFdocument 20140603 referred to that date is BLANK.. with type error inside..


    UPDATE: the only solution that I've found is changing settings in Windows -.-° another solution? :P

  12. #57
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,921
    Setting the format property in table or textbox does not alter the actual value used by search and filter. Must use Format function which results in a string value.

    I do not fully understand how to deal with international dates because not a concern for me. I do know that if you want to have users input values as dd/mm/yyyy structure, life will be very frustrating.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  13. #58
    ingarchsf is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2014
    Posts
    50
    @June7: ok, so, that is not a problem, editing Windows settings..

    @ssanfu: The other thing to add is: in the Form I need to use also 2 number boxes (N_corso and N_modulo) which have 2 parameters (qncorso1 and qnmodulo1), which are used to select records inside Selezione_corso_2014.
    I've tried to add a "WHERE" condition, but I'm not able -.-°

    This is the base code, edited for my db, and it works. I need to add other 2 parameters to make the selection (at least one) besides "cognome" [N_corso and N_modulo are numeric fields]
    Code:
    Private Sub ExportPDF_Click()
        Dim MyDB As DAO.Database
        Dim MyRS As DAO.Recordset
        Dim strSQL As String
        Dim strRptName As String
        Dim sCriteria As String
        Set MyDB = CurrentDb
        strRptName = "Attestati_2014"
       
        strSQL = "Select Selezione_corso_2014.[Cognome], Selezione_corso_2014.[Data_modulo] From Selezione_corso_2014 "
        strSQL = strSQL & " WHERE Cognome ='" & Me.qcognome1 & "'" & " WHERE N_corso =" & Me.qncorso1 & "" & " WHERE N_modulo =" & Me.qnmodulo1 &""
        Set MyRS = MyDB.OpenRecordset(strSQL, dbOpenForwardOnly)
        
        
        With MyRS
            Do While Not MyRS.EOF
                sCriteria = "[Cognome]='" & ![Cognome] & "' and [Data_modulo] = #" & ![Data_modulo] & "#"
                DoCmd.OpenReport strRptName, acViewPreview, , sCriteria
                
                DoCmd.OutputTo acOutputReport, strRptName, acFormatPDF, "C:\Attestati\" & ![Cognome] & "_" & Format(![Data_modulo], "YYYYMMDD") & ".pdf", False
                DoCmd.Close acReport, strRptName
                .MoveNext
            Loop
        End With
        MyRS.Close
        Set MyRS = Nothing
        MsgBox "Done"
    End Sub

  14. #59
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,921
    Don't repeat the WHERE key word. It is used only once in an SQL statement.

    " WHERE Cognome ='" & Me.qcognome1 & "' AND N_corso =" & Me.qncorso1 & " AND N_modulo =" & Me.qnmodulo1
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  15. #60
    ingarchsf is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2014
    Posts
    50
    Quote Originally Posted by June7 View Post
    Don't repeat the WHERE key word. It is used only once in an SQL statement.

    " WHERE Cognome ='" & Me.qcognome1 & "' AND N_corso =" & Me.qncorso1 & " AND N_modulo =" & Me.qnmodulo1
    it doesn't work however.. syntax error

    Code:
    strSQL = strSQL & " WHERE Cognome ='" & Me.qcognome1 & "' AND N_corso =" & Me.qncorso1 & " AND N_modulo =" & Me.qnmodulo1 "

Page 4 of 7 FirstFirst 1234567 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 06-04-2014, 01:25 PM
  2. Export as PDF
    By lugnutmonkey in forum Import/Export Data
    Replies: 1
    Last Post: 02-19-2013, 11:23 AM
  3. Export to Word
    By Monterey_Manzer in forum Import/Export Data
    Replies: 0
    Last Post: 12-20-2012, 02:06 PM
  4. CSV Export
    By mchadwick in forum Access
    Replies: 1
    Last Post: 09-06-2011, 03:19 PM
  5. Export
    By vvasudev in forum Import/Export Data
    Replies: 2
    Last Post: 01-20-2010, 11:42 AM

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