|
-
Jun 21st, 2005, 08:49 PM
#1
Thread Starter
Addicted Member
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:
Dim strDocName As String
Dim strWhere As String
strWhere = "[PatID]=" & Me.PatID
strDocName = "Patient"
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.
Last edited by techwizz; Jun 21st, 2005 at 10:04 PM.
Reason: Finishes
-
Jun 21st, 2005, 09:10 PM
#2
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:
'Report recordsource:
SELECT
[Patient].[PatID] AS [color=red][b]Patient_PatID[/b][/color],
[Patient].[PatName],
[Patient].[Total],
[Apointment].[AppID],
[Apointment].[PatID] AS Apointment_PatID,
[Apointment].[1],
[Apointment].[2],
[Apointment].[3],
[Apointment].[4],
[Apointment].[5],
[Apointment].[Appointment]
FROM Patient
INNER JOIN Apointment ON [Patient].[PatID]=[Apointment].[PatID];
'Form Print Prieview procedure:
Private Sub Command11_Click()
On Error GoTo Err_Command11_Click
Dim strDocName As String
Dim strWhere As String
strWhere = "[color=navy][b][Patient].[Patient_PatID][/b][/color]=" & Me.PatID
strDocName = "Patient"
DoCmd.OpenReport strDocName, acPreview, , strWhere
Exit_Command11_Click:
Exit Sub
Err_Command11_Click:
MsgBox Err.Description
Resume Exit_Command11_Click
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Jun 21st, 2005, 10:03 PM
#3
Thread Starter
Addicted Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|