A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Setting Up & Running Reports
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Opening a report from a button on a subform



 
 
Thread Tools Display Modes
  #1  
Old August 7th, 2007, 08:47 AM posted to microsoft.public.access,microsoft.public.access.forms,microsoft.public.access.formscoding,microsoft.public.access.reports
John S. Ford, MD
external usenet poster
 
Posts: 215
Default Opening a report from a button on a subform

I have a main form frmPatients with a subform sbfPatientAppointment. The
main form contains general information about a patient and the subform
contains information from a particular visit (appointment) with that that
patient.

The underlying table for the subform contains a primary field
PatientVisitIDNum.

I want to place a command button cmdPrintVisit on the subform and have it
open a report that is based ONLY on the information on the visit being
worked on (of the patient reflected in the main form). In other words, I
want to filter the report's underlying query to limit it only to the
PatientVisitIDNum of the visit being worked on.

I'm assuming I can use the DoCmd.OpenReport method using the wherecondition
argument where wherecondition = "PatientVisitIDNum =
currentPatientVisitIDNum". How do I populate the currentPatientVisitIDNum
with the correct value?

Any ideas?

John


  #2  
Old August 7th, 2007, 08:56 AM posted to microsoft.public.access,microsoft.public.access.forms,microsoft.public.access.formscoding,microsoft.public.access.reports
Allen Browne
external usenet poster
 
Posts: 11,706
Default Opening a report from a button on a subform

Concatenate the value of the control into the WhereCondition string:

Dim strWhere As String
If Me.Dirty Then Me.Dirty = False
If Me.NewRecord Then
MsgBox "Select a visit to print."
Else
strWhere = "PatientVisitIDNum = " & Me.PatientVisitIDNum
Docmd.OpenReport "Report1", acViewPreivew, strWhere
End If

Explanation:
Print the record in the form
at:
http://allenbrowne.com/casu-15.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"John S. Ford, MD" wrote in message
...
I have a main form frmPatients with a subform sbfPatientAppointment. The
main form contains general information about a patient and the subform
contains information from a particular visit (appointment) with that that
patient.

The underlying table for the subform contains a primary field
PatientVisitIDNum.

I want to place a command button cmdPrintVisit on the subform and have it
open a report that is based ONLY on the information on the visit being
worked on (of the patient reflected in the main form). In other words, I
want to filter the report's underlying query to limit it only to the
PatientVisitIDNum of the visit being worked on.

I'm assuming I can use the DoCmd.OpenReport method using the
wherecondition argument where wherecondition = "PatientVisitIDNum =
currentPatientVisitIDNum". How do I populate the currentPatientVisitIDNum
with the correct value?

Any ideas?

John


  #3  
Old August 7th, 2007, 09:04 AM posted to microsoft.public.access,microsoft.public.access.forms,microsoft.public.access.formscoding,microsoft.public.access.reports
John S. Ford, MD
external usenet poster
 
Posts: 215
Default Opening a report from a button on a subform

Allen,

PatientVisitIDNum is an autonumber not a value placed into a TextBox. It is
created everytime a new visit is begun.

Can I access that field from Me.PatientVisitIDNum?

John


"Allen Browne" wrote in message
...
Concatenate the value of the control into the WhereCondition string:

Dim strWhere As String
If Me.Dirty Then Me.Dirty = False
If Me.NewRecord Then
MsgBox "Select a visit to print."
Else
strWhere = "PatientVisitIDNum = " & Me.PatientVisitIDNum
Docmd.OpenReport "Report1", acViewPreivew, strWhere
End If

Explanation:
Print the record in the form
at:
http://allenbrowne.com/casu-15.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"John S. Ford, MD" wrote in message
...
I have a main form frmPatients with a subform sbfPatientAppointment. The
main form contains general information about a patient and the subform
contains information from a particular visit (appointment) with that that
patient.

The underlying table for the subform contains a primary field
PatientVisitIDNum.

I want to place a command button cmdPrintVisit on the subform and have it
open a report that is based ONLY on the information on the visit being
worked on (of the patient reflected in the main form). In other words, I
want to filter the report's underlying query to limit it only to the
PatientVisitIDNum of the visit being worked on.

I'm assuming I can use the DoCmd.OpenReport method using the
wherecondition argument where wherecondition = "PatientVisitIDNum =
currentPatientVisitIDNum". How do I populate the
currentPatientVisitIDNum with the correct value?

Any ideas?

John




  #4  
Old August 7th, 2007, 09:10 AM posted to microsoft.public.access,microsoft.public.access.forms,microsoft.public.access.formscoding,microsoft.public.access.reports
Allen Browne
external usenet poster
 
Posts: 11,706
Default Opening a report from a button on a subform

Yes.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"John S. Ford, MD" wrote in message
...
Allen,

PatientVisitIDNum is an autonumber not a value placed into a TextBox. It
is created everytime a new visit is begun.

Can I access that field from Me.PatientVisitIDNum?

John


"Allen Browne" wrote in message
...
Concatenate the value of the control into the WhereCondition string:

Dim strWhere As String
If Me.Dirty Then Me.Dirty = False
If Me.NewRecord Then
MsgBox "Select a visit to print."
Else
strWhere = "PatientVisitIDNum = " & Me.PatientVisitIDNum
Docmd.OpenReport "Report1", acViewPreivew, strWhere
End If

Explanation:
Print the record in the form
at:
http://allenbrowne.com/casu-15.html

"John S. Ford, MD" wrote in message
...
I have a main form frmPatients with a subform sbfPatientAppointment. The
main form contains general information about a patient and the subform
contains information from a particular visit (appointment) with that that
patient.

The underlying table for the subform contains a primary field
PatientVisitIDNum.

I want to place a command button cmdPrintVisit on the subform and have
it open a report that is based ONLY on the information on the visit
being worked on (of the patient reflected in the main form). In other
words, I want to filter the report's underlying query to limit it only
to the PatientVisitIDNum of the visit being worked on.

I'm assuming I can use the DoCmd.OpenReport method using the
wherecondition argument where wherecondition = "PatientVisitIDNum =
currentPatientVisitIDNum". How do I populate the
currentPatientVisitIDNum with the correct value?

Any ideas?

John


  #5  
Old August 7th, 2007, 09:15 AM posted to microsoft.public.access,microsoft.public.access.forms,microsoft.public.access.formscoding,microsoft.public.access.reports
John S. Ford, MD
external usenet poster
 
Posts: 215
Default Opening a report from a button on a subform

Thank you very much Allen. I'll try that!

John

"Allen Browne" wrote in message
...
Yes.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"John S. Ford, MD" wrote in message
...
Allen,

PatientVisitIDNum is an autonumber not a value placed into a TextBox. It
is created everytime a new visit is begun.
!
Can I access that field from Me.PatientVisitIDNum?

John



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 05:48 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.