alex1283
Jun 9 2006, 01:24 AM
Hallo,
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).
thanks
Alex
projecttoday
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.
Robert
kapeller
Jun 9 2006, 02:27 AM
Hi Alex
Have a look at this
example Cheers!!!!
lou
alex1283
Jun 9 2006, 03:06 AM
ok,
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
alex
kapeller
Jun 9 2006, 03:10 AM
You are welcome.......
Cheers!!!
lou
alex1283
Jun 9 2006, 05:19 AM
Hi Lou,
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 & """"
End If
stDocName = "br_tracking"
DoCmd.OpenReport stDocName, acPreview, , sCriteria
Exit_Bericht_Click:
Exit Sub
Err_Bericht_Click:
MsgBox Err.Description
Resume Exit_Bericht_Click
End Sub
thanks
alex
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please
click here.