1 Attachment(s)
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.... :mad:
I attatched a file.
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
Re: Error trying to print records of current form page only!
Thannk You So Much RobbDogg.
I appreciate the help!
Resolved! Robbs a lifesaver!
;)