Results 1 to 9 of 9
  1. #1
    Join Date
    May 2012
    Posts
    4

    Unanswered: Printing current record on form as report format

    I have an Access database where I have a couple of command buttons on the bottom of a form.
    Both of these buttons allows the user to print a 'GP Report' and a 'Patient Report' which are reports that I have created within the database.

    However whenever I go to print the current record that I am inputting in the form it doesn't do it. It just prints out blank.

    I'm miffed!

    Please help!

    I've attached it for people to see - I've inputted some dummy records for confidentiality reasons.
    Attached Files Attached Files

  2. #2
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    If you want people to help you by looking at your password-protected database, it would be helpful if you were to give us the password!

    But just as a guess, it sounds as if you're trying to print a Report on the Current Record before the Record has actually been Saved, i.e. before it is actually a Record!

    Linq ;0)>
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  3. #3
    Join Date
    May 2012
    Posts
    4

    Password unset now

    Here's the database without the password! oops sorry! I forgot it had a password.

    I have been saving the record as I've been entering it - I've even added extra save buttons as you work down the form.
    Attached Files Attached Files

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    apply a filkter as part of the Open report macro
    OpenReport Macro Action
    or Google

    BTW
    I see no relationships in that design.. not a smart call.
    where I'd expect to see realtinships theres's no primary key for most of the'parent tables', as you have in the tblPractices
    I'd rather be riding on the Tiger 800 or the Norton

  5. #5
    Join Date
    May 2012
    Posts
    4
    What sort of filter? Sorry I'm being thick

  6. #6
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    prob best to use a "where clause" as the 4th parameter on the open report macro
    I'd rather be riding on the Tiger 800 or the Norton

  7. #7
    Join Date
    Dec 2010
    Location
    Manchester
    Posts
    24
    Create a new module and put this code in

    Code:
    Function PrintReport(stDocName As String, stLinkCriteria As String)
    Dim Result As Long
    On Error GoTo Err_Preview_Click
    
        Result = MsgBox("Preview report before printing?", 35, Systemtitle)
            Select Case (Result)
                Case 6
                    DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria
                    
                Case 7
                    DoCmd.OpenReport stDocName, , , stLinkCriteria
            End Select
    Exit_Preview_Click:
        Exit Function
    
    Err_Preview_Click:
        If Err = 2501 Then
            Resume Exit_Preview_Click
        Else
            MsgBox "ERROR: Unable to print report!" & vbNewLine & vbNewLine & Error, 64, Systemtitle
            Resume Exit_Preview_Click
        End If
    
    End Function
    Then on your print button simple put

    Code:
    Private Sub Button()
    PrintReport "REPORTNAME", "CRITERIA" & FIELD
    End Sub
    E.g PrintReport "testreport", "ID = " & IDtextbox

    This should work
    Code:
    If Me.OpenAccess.Work Then
    Access.Crash = Inevitable
    End If
    Me.BangHeadAgainstWall = Headache

    I dont need you to solve my problem, just give me a push in the right direction.

  8. #8
    Join Date
    May 2012
    Posts
    4

    Nope...still no luck

    I really don't think I'm doing things right - in fact I feel completely lost now.
    Attached Files Attached Files

  9. #9
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    read the supplied links
    set a where clause for the openreport macro.
    its the 4th paramter
    it will take the form of
    mycolumname = blah
    eg
    "myusername = 'sarahseager'" for a string column
    "myUserId = 234" for a numeric column
    where myusername/myuserid is the name of the column that conatins the claue you are looking for
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

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