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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|