Jun 9 2006, 01:24 AM
I have a form which base on a query. in the form you can type in a date to search for.
a vba code than filter the record source.
now I would like to copy the results in a report.
find attached the vba code for the search button (works) and the report (doesn't run).
Jun 9 2006, 02:19 AM
I think your docmd.openreport is wrong. stDocnam (the first parameter) should be the name of the report. And your where clause - what is QRY_tracking. I see it used several ways.
Jun 9 2006, 02:27 AM
Have a look at this example
Jun 9 2006, 03:06 AM
I changed the report name to br_tracking, because as robert told me the name was used several ways.
but it doesn't work so far. I can't see my fault in the code. the criteria must be wrong because access opens the report but not with the right source. i will try to find the mistake with the help of lou's example.
thanks so far
Jun 9 2006, 03:10 AM
You are welcome.......
Jun 9 2006, 05:19 AM
I tried your code which look similar to my old one, but it doesn't work. What is wrong?
filtern: name of the field in the form to type in the date to search.
qry_tracking: query with the information
steuerkreis: field name in the query
br_tracking: report which open but with all information
Private Sub Bericht_Click()
On Error GoTo Err_Bericht_Click
Dim stDocName As String
Dim sCriteria As String
If filtern <> "" Then
sCriteria = "qry_tracking.Steuerkreis = """ & filtern & """"
stDocName = "br_tracking"
DoCmd.OpenReport stDocName, acPreview, , sCriteria
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here