Results 1 to 6 of 6
  1. #1
    Join Date
    Jun 2003
    Location
    Fort Myers, FL 33907
    Posts
    5

    Unanswered: Print Current Report

    I am tring to print one record out of a report based on the information on the screen. I have tried 2 different pieces of code. I get the same error on both.

    I have a field of "MID" (Merchant ID Number). This is a number that is never duplicated. some thing like 544068086947161. My tabel dose not have a primary key.

    Here is the code that I have Tried.

    stDocName = "Merchant Manager Printout"
    stLinkCriteria = "[Merchant Manager].[MID]=" & Me![MID]

    DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria


    And Also This One

    Dim strDocName As String
    Dim strWhere As String
    strDocName = "Merchant Manager Printout"
    strWhere = "[MID]=" & me!MID
    DoCmd.OpenReport strDocName, acPreview, , strWhere


    Hope someone can help.
    I am new to programming access.

    ~Gary

  2. #2
    Join Date
    Aug 2002
    Location
    Melbourne, Australia
    Posts
    111
    Gary,

    What is the error message you are receiving?

    Try this is code behind you command button, I think I have changed to suit , but just give it a quick look over please.

    Sometimes the problem is that you have created a new record (filled in the form) and because you have not closed and re-opened the form or you have not moved to another record and then back the record has not been saved.

    This code works fine for me in several db's, when you get it working then enter you own error coding.



    Dim StrCriterion As String
    Dim strMsg As String, strTitle As String
    Dim intStyle As Integer

    'Check to see if the record is blank.

    If IsNull(Me![MID]) Then
    strMsg = "You cannot Print a Blank Form !!."
    strTitle = "Label Print Error"
    intStyle = vbOKOnly
    MsgBox strMsg, intStyle, strTitle

    Exit Sub
    End If

    ' If the record is not blank then it saves it, also when you have just created a new record and try and print it
    ' it will not have been "saved" so this will do it.

    If Me.Dirty Then
    Me.Dirty = False
    End If

    ' This will establish the link, and print the report.

    StrCriterion = "[Merchant Manager].[MID]=" & Me![MID]

    DoCmd.OpenReport "Merchant Manager Printout", acNormal, , StrCriterion



    Regards



    Regards,



    John A

  3. #3
    Join Date
    Jun 2003
    Location
    Fort Myers, FL 33907
    Posts
    5
    Thanks again....

    I tried your code and this what i got.

    Error 3464
    Data Type Mismatch

    I don't understand that one.

    ~Gary

  4. #4
    Join Date
    Aug 2002
    Location
    Melbourne, Australia
    Posts
    111

    Print Current Record

    Do both of these fields come from the same table and if not are they the same type eg number (Long Integer).

    To me what it is say is that Merchant Manager.Mid is not the same data type as Me.MID

    This is you problem area.

    StrCriterion = "[Merchant Manager].[MID]=" & Me![MID]


    I will be online for about another 15 minutes so let me know and I will send you a sample db

    Regards
    Regards,



    John A

  5. #5
    Join Date
    Jun 2003
    Location
    Fort Myers, FL 33907
    Posts
    5
    They are long numbers about 15 numbers

    They are in the one tabel everything is one tabel

  6. #6
    Join Date
    Aug 2002
    Location
    Melbourne, Australia
    Posts
    111
    Attached is my sample, Have a look behind the Print Preview button.

    If you want to print in lieu of preview change the following

    DoCmd.OpenReport "Rpt_Customer", acPreview, , StrCriterion


    to


    DoCmd.OpenReport "Rpt_Customer", acNormal, , StrCriterion


    If you want to post your database I will have a look at it .


    Regards
    Attached Files Attached Files
    Regards,



    John A

Posting Permissions

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