Create a Report from a Filtered Form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a large employee table. I am able to select the desired employee id from the drop down box and after clikcing on the command button a new form opens where all the employee information is stored. Some times there are multiple values for the same employees (these records are filtered) Is there a way for me to create a report from the filtered form. Please help Thanks........
 
Create a report that you want and select the table/query that contains the
data(fields) you want on the report. Open the properties window
(View/Properties) on the main menu. Select the ellipsis(...) next to the On
Open event to open the code window. Cut and paste the following code
replacing the names to the names in your app. Also make sure the Filter On
and Order By On are set to true in the properties window.


Private Sub Report_Open(Cancel As Integer)

Me.RecordSource = Forms!MyFormName.Form.RecordSource

With Forms!MyFormName.Form
If .OrderByOn Then
Me.OrderBy = .OrderBy
Me.OrderByOn = True
End If
If .FilterOn Then
Me.Filter = .Filter
Me.FilterOn = True
End If
End With
DoCmd.Maximize
End Sub

Hope this helps!
--
Reggie

www.smittysinet.com
----------
Deezle said:
I have a large employee table. I am able to select the desired employee id
from the drop down box and after clikcing on the command button a new form
opens where all the employee information is stored. Some times there are
multiple values for the same employees (these records are filtered) Is there
a way for me to create a report from the filtered form. Please help
Thanks........
 
Thanks for the response. I am still not able to get the desired report. I have created a report based on the table that I am using for the Form. The form name is "activerev" and the name of the report is "act_rev_rp". If I put the name of the Form in the VB code I get a run time Error 2450 and it says it's not able to find the form activerev. I have copied and pasted the code as under:

Private Sub Report_Open(Cancel As Integer)

Me.RecordSource = Forms!activerev.RecordSource
With Forms!activerev.Form
If .OrderByOn Then
Me.OrderBy = .OrderBy
Me.OrderByOn = True
End If
If .FilterOn Then
Me.Filter = .Filter
Me.FilterOn = True
End If
End With
DoCmd.Maximize

End Sub

Please help.
Thanks.........

----- Reggie wrote: -----

Create a report that you want and select the table/query that contains the
data(fields) you want on the report. Open the properties window
(View/Properties) on the main menu. Select the ellipsis(...) next to the On
Open event to open the code window. Cut and paste the following code
replacing the names to the names in your app. Also make sure the Filter On
and Order By On are set to true in the properties window.


Private Sub Report_Open(Cancel As Integer)

Me.RecordSource = Forms!MyFormName.Form.RecordSource

With Forms!MyFormName.Form
If .OrderByOn Then
Me.OrderBy = .OrderBy
Me.OrderByOn = True
End If
If .FilterOn Then
Me.Filter = .Filter
Me.FilterOn = True
End If
End With
DoCmd.Maximize
End Sub

Hope this helps!
--
Reggie

www.smittysinet.com
----------
Deezle said:
I have a large employee table. I am able to select the desired employee id
from the drop down box and after clikcing on the command button a new form
opens where all the employee information is stored. Some times there are
multiple values for the same employees (these records are filtered) Is there
a way for me to create a report from the filtered form. Please help
Thanks........
 
The form has to be open when you open the report. I assume you are clicking
a command button on the form to open the report. If so don't close the
form. The other possibility is that the activerev is a subform of the main
form. If so you need to reference it as so:

Me.RecordSource = Forms!frmMainForm!activerev.Form.RecordSource

Hope this helps!

--
Reggie

www.smittysinet.com
----------
Deezel said:
Thanks for the response. I am still not able to get the desired report. I
have created a report based on the table that I am using for the Form. The
form name is "activerev" and the name of the report is "act_rev_rp". If I
put the name of the Form in the VB code I get a run time Error 2450 and it
says it's not able to find the form activerev. I have copied and pasted the
code as under:
 
Back
Top