Sorry for the lengthy description but I hope to make this issue I am having as clear as possible.
I have a report that I have developed which is associated with a contact's name on an "AIA Firm Contact form". The only way I can currently get the report to open and only show that contact's info, is to have the underlying report query prompt the user to enter the contact's name. I have a "Report" button on the contact form that allows the user to click the button and just enter the contact name and the report shows up with the information I desire. (See attached .jpg)
Rather than having the user enter a contact's name each time, what code can I write so upon clicking the "Report" button, the report automatically associates the Contact's name on the AIA Firm Contact form and the report opens up showing ONLY that contact's information.
Below is the code I wrote to open the FORM for one contact at a time. It works perfectly as it only opens the contact on the form.
---------------------------------------------
Private Sub open_Rpt_Spec_Details_AIA_Contact_Click()
On Error GoTo Err_open_Rpt_Spec_Details_AIA_Contact_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "rpt_Spec_Details_AIA_Contact"
stLinkCriteria = [ContactName] = "&" & Me![ContactName] & " '"
DoCmd.OpenReport stDocName, acPreview
Exit_open_Rpt_Spec_Details_AIA_Contact_C:
Exit Sub
Err_open_Rpt_Spec_Details_AIA_Contact_Click:
MsgBox Err.Description
Resume Exit_open_Rpt_Spec_Details_AIA_Contact_C
End Sub
-------------------------------------------------
Below is the code I wrote to have the REPORT Open to the contact's name on the form that is open. The report shows the information properly BUT shows EVERY contact's information, rather than ONLY the immediate contact on AIA Firm Contact form.
----------------------------------------------------------
Private Sub open_frm_Job_Spec_DetailxProj_AIA_Click()
On Error GoTo Err_open_frm_Job_Spec_DetailxProj_AIA_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frm_Job_Spec_DetailxProj_AIA"
stLinkCriteria = "[ContactName]=" & "'" & Me![ContactName] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_open_frm_Job_Spec_DetailxProj_AIA_Clic:
Exit Sub
Err_open_frm_Job_Spec_DetailxProj_AIA_Click:
MsgBox Err.Description
Resume Exit_open_frm_Job_Spec_DetailxProj_AIA_Clic
End Sub
------------------------------------------------
Thank you in advance for your help......Mark
I have a report that I have developed which is associated with a contact's name on an "AIA Firm Contact form". The only way I can currently get the report to open and only show that contact's info, is to have the underlying report query prompt the user to enter the contact's name. I have a "Report" button on the contact form that allows the user to click the button and just enter the contact name and the report shows up with the information I desire. (See attached .jpg)
Rather than having the user enter a contact's name each time, what code can I write so upon clicking the "Report" button, the report automatically associates the Contact's name on the AIA Firm Contact form and the report opens up showing ONLY that contact's information.
Below is the code I wrote to open the FORM for one contact at a time. It works perfectly as it only opens the contact on the form.
---------------------------------------------
Private Sub open_Rpt_Spec_Details_AIA_Contact_Click()
On Error GoTo Err_open_Rpt_Spec_Details_AIA_Contact_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "rpt_Spec_Details_AIA_Contact"
stLinkCriteria = [ContactName] = "&" & Me![ContactName] & " '"
DoCmd.OpenReport stDocName, acPreview
Exit_open_Rpt_Spec_Details_AIA_Contact_C:
Exit Sub
Err_open_Rpt_Spec_Details_AIA_Contact_Click:
MsgBox Err.Description
Resume Exit_open_Rpt_Spec_Details_AIA_Contact_C
End Sub
-------------------------------------------------
Below is the code I wrote to have the REPORT Open to the contact's name on the form that is open. The report shows the information properly BUT shows EVERY contact's information, rather than ONLY the immediate contact on AIA Firm Contact form.
----------------------------------------------------------
Private Sub open_frm_Job_Spec_DetailxProj_AIA_Click()
On Error GoTo Err_open_frm_Job_Spec_DetailxProj_AIA_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frm_Job_Spec_DetailxProj_AIA"
stLinkCriteria = "[ContactName]=" & "'" & Me![ContactName] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_open_frm_Job_Spec_DetailxProj_AIA_Clic:
Exit Sub
Err_open_frm_Job_Spec_DetailxProj_AIA_Click:
MsgBox Err.Description
Resume Exit_open_frm_Job_Spec_DetailxProj_AIA_Clic
End Sub
------------------------------------------------
Thank you in advance for your help......Mark