Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    hrseebeck is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Aug 2012
    Posts
    15

    Run-time Error '3464' With A Print Cmd in Access 07

    Good morning! I have created a form that has a button to open the form record as a report; however, I am receiving a run-tim error of 3464: Data type mismatch in criteria expression. My code looks like this:

    Private Sub cmdPrintRecord_Click()

    Dim strReportName As String
    Dim strCriteria As String

    strReportName = "rptPrintRecord"
    strCriteria = "[QuoteNo]='" & Me![QuoteNo] & "'"
    DoCmd.OpenReport strrptPrintReport, acViewPreview, , strCriteria

    End Sub

    The error is highlighting the last line. Any ideas what may be the issue?

    Thank you

  2. #2
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,847
    Try
    DoCmd.OpenReport strReportName, acViewPreview, , strCriteria

  3. #3
    hrseebeck is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Aug 2012
    Posts
    15
    Thank you for such a quick response. Unfortunatly the new code didn't work. Could there be an issue because my form has a subform and the report I am printing to has the same format including the subreport?

  4. #4
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    The error message says "Data type mismatch in criteria expression," so the pertinent question should be is the Field named QuoteNo defined as a Number or as Text? The syntax you're using is only correct if the Field is defined as a Text Datatype. If QuoteNo is defined as a Number, the correct syntax would be

    strCriteria = "[QuoteNo]=" & Me![QuoteNo]

    Given the code you posted, I'd also have to guess that orange's suggestion of

    DoCmd.OpenReport strReportName, acViewPreview, , strCriteria


    is probably also correct! The strrptPrintReport in the line

    DoCmd.OpenReport strrptPrintReport, acViewPreview, , strCriteria

    looks suspiciously like a mixed up concatenation of strReportName and rptPrintRecord.

    You should always keep in mind that when trouble-shooting something like this, you can have multiple errors, and the second error will only become evident when the first error is resolved, the third when the first and second errors become resolved, and so forth.

    Linq :0)>

  5. #5
    hrseebeck is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Aug 2012
    Posts
    15
    Thank you all so much! The main form now works but the subform won't come through. I added a line of code: strCriteria = "[QuoteNo]=" & Forms!frmQuoteSF [QuoteID] but it also is not working. The links are QuoteNo from the main form and the child link for the subform is QuoteID, both are numeral fields. Any help would be most appreciative.

  6. #6
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,847
    Is there really a space in the strCriteria? If so there shouldn't be.

    strCriteria = "[QuoteNo]=" & Forms!frmQuoteSF [QuoteID]

    Here's a link to form/control referencing syntax.
    http://access.mvps.org/access/forms/frm0031.htm

  7. #7
    hrseebeck is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Aug 2012
    Posts
    15
    Thank you. I used the code line you provided but I am receiving a Compile error: Syntax Error. I review the link you provided but I was unable to get it to work.

  8. #8
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,847
    The line in my last post is a copy of the line from your post#5. I was suggesting if there is really a space in that line, then it's probably an ERROR.

    The link I gave shows the syntax for referencing controls on MainForm, subform1, subsubform etc.

  9. #9
    hrseebeck is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Aug 2012
    Posts
    15
    The space was removed but I am still not getting my subform to show in the subreport for that particular quote. I have tried to add a line of code strCriteria = "[QuoteID]=" & me!Subform1.Form!frmQuoteSF[QuoteID] to get the info from the subform but I am still getting an error. Any help?

  10. #10
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,847
    Are you gettingan error message? If so, please provide the message text/number.

    Can you post a copy of your database - remove anything private/confidential?

  11. #11
    hrseebeck is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Aug 2012
    Posts
    15
    The error that I get is Compile Error: Expected: end of statement.

    My coding is :

    Private Sub Command62_Click()
    Dim strReportName As String
    Dim strCriteria As String
    strReportName = "rptPrintRecord"
    strCriteria = "[QuoteNo]=" & Me![QuoteNo]
    strCriteria = "[QuoteID]=" & me!Subform1.Form!frmQuoteSF[QuoteID]
    DoCmd.OpenReport strReportName, acViewPreview, , strCriteria

    End Sub

  12. #12
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,847
    Your code is over writing strcriteria --- I don't think that's what you intended.

    Can you post your database? (remove private info.)

  13. #13
    hrseebeck is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Aug 2012
    Posts
    15
    Here is the database. Thank you for your help.
    Attached Files Attached Files

  14. #14
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,847
    I don't see any buttons on your forms.

    Perhaps you should tell us exactly which form, which control etc.

    Only the Customers form looks like a form, the other are just print on a white page -- no obvious controls.
    Have no idea what to look for.

  15. #15
    hrseebeck is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Aug 2012
    Posts
    15
    My apologies. The button I am trying to code is located on the frmQuote sheet. I have uploaded a new database where the button is visible (for some reason the previous one wasn't showing up).AccessForums2.zip

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Run-time error '3464' Date criteria
    By tylerg11 in forum Forms
    Replies: 3
    Last Post: 12-30-2011, 12:34 PM
  2. Error 3464 Reserved Error
    By e.badin in forum Reports
    Replies: 6
    Last Post: 07-18-2011, 02:47 PM
  3. Replies: 2
    Last Post: 12-23-2010, 09:11 AM
  4. Error when trying to print or print preview
    By TriAdX in forum Reports
    Replies: 8
    Last Post: 08-25-2009, 08:20 AM
  5. 3464 error received
    By TEN in forum Programming
    Replies: 10
    Last Post: 07-08-2009, 07:25 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