Results 1 to 3 of 3

Thread: Error trying to print records of current form page only! [Resolved]

  1. #1

    Thread Starter
    Addicted Member techwizz's Avatar
    Join Date
    Apr 2005
    Location
    U.S.A.
    Posts
    246

    Exclamation Error trying to print records of current form page only! [Resolved]

    Hello vbforums.com,

    I am trying to print only the current data from a form in access. Includes data from a subform.

    Ive done it before and am actually using the same code.. with no success. Maybe someone can help...

    The report to be called is name Patient

    I want to print only current PatID ... but its not working as i said.

    I use the following code.

    VB Code:
    1. Dim strDocName As String
    2.     Dim strWhere As String
    3.    
    4.     strWhere = "[PatID]=" & Me.PatID
    5.     strDocName = "Patient"
    6.     DoCmd.OpenReport strDocName, acPreview, , strWhere

    It keeps asking me for the PatID.... even though it is plainly displayed on the form.

    Also with some changes tells me i have to many (

    Heeeelp....

    I attatched a file.
    Attached Files Attached Files
    Last edited by techwizz; Jun 21st, 2005 at 10:04 PM. Reason: Finishes

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Error trying to print records of current form page only!

    Your aliasing the PatID field in your report recordsource and so it doesnt know what PatID is, only "Patient_PatID" alias.

    When you have multiple tables with the same field name you can alias them like you did but you need to refe to them using the alian name.

    VB Code:
    1. 'Report recordsource:
    2. SELECT
    3.  [Patient].[PatID] AS [color=red][b]Patient_PatID[/b][/color],
    4.  [Patient].[PatName],
    5.  [Patient].[Total],
    6.  [Apointment].[AppID],
    7.  [Apointment].[PatID] AS Apointment_PatID,
    8.  [Apointment].[1],
    9.  [Apointment].[2],
    10.  [Apointment].[3],
    11.  [Apointment].[4],
    12.  [Apointment].[5],
    13.  [Apointment].[Appointment]
    14. FROM Patient
    15. INNER JOIN Apointment ON [Patient].[PatID]=[Apointment].[PatID];
    16.  
    17. 'Form Print Prieview procedure:
    18. Private Sub Command11_Click()
    19. On Error GoTo Err_Command11_Click
    20.  
    21.     Dim strDocName As String
    22.     Dim strWhere As String
    23.    
    24.     strWhere = "[color=navy][b][Patient].[Patient_PatID][/b][/color]=" & Me.PatID
    25.     strDocName = "Patient"
    26.     DoCmd.OpenReport strDocName, acPreview, , strWhere
    27.  
    28. Exit_Command11_Click:
    29.     Exit Sub
    30.  
    31. Err_Command11_Click:
    32.     MsgBox Err.Description
    33.     Resume Exit_Command11_Click
    34.    
    35. End Sub
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Addicted Member techwizz's Avatar
    Join Date
    Apr 2005
    Location
    U.S.A.
    Posts
    246

    Re: Error trying to print records of current form page only!

    Thannk You So Much RobbDogg.

    I appreciate the help!

    Resolved! Robbs a lifesaver!


Posting Permissions

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



Click Here to Expand Forum to Full Width