|
|
|
date: Wed, 20 Aug 2008 14:48:02 -0700,
group: microsoft.public.access.reports
back
Re: Cmd Button on Form for Filtered Report
Mr. Browne - Thanks for the tips - unfortunity, I'm still getting all records
and not the specific one's I need. :(
this is driving me nuts because I know it's something simple...
I've replaced my code with the example you provided...
Private Sub cmdPrint_Click()
Dim strWhere As String
If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If
If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[receipt#] = " & Me.[receipt#]
DoCmd.OpenReport "warehouse_receipt2", acViewPreview, , strWhere
End If
End Sub
Do you think maybe my report is set up wrong? Maybe the grouping? I don't
know... I'm truely frusterated. My boss is starting to eyebrow me and I
don't want to abandon this project to excel...
--
Shelyons
"Allen Browne" wrote:
> 1. Double-check that the report is not already open -- not even in design
> view.
>
> 2. If you open your table in design view, what is the data type of your
> receipt# field? If Number (not Text), lose the extra quotes.
>
> 3. Make sure the record is saved.
>
> 4. Make sure there is a record (form is not at a new record.
>
> 5. Use a string for the WhereCondition, so you can Debug.Print it to check
> the results.
>
> Further example:
> 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.
>
> "Shelyons" wrote in message
> news:963FABC8-0558-4418-992B-E2D873526D53@microsoft.com...
> >I am using Access 2000. I am building a warehouse database that needs to
> > produce a warehouse receipt. I have a form for the customer data which
> > includes a subform for the product data. I have a cmd button that
> > "should"
> > create a report that is based on a query of both tables. I need the
> > report
> > to only be reflective of the for data currently displayed on the form.
> > Instead I get a report that includes ALL records. Here is my code. Can
> > you
> > help?
> >
> > Private Sub CmdPrint_Click()
> >
> > Dim stDocName As String
> >
> > DoCmd.OpenReport "WAREHOUSE_RECEIPT2", acViewPreview, , "[receipt#] = '" &
> > [receipt#] & "'"
> >
> >
> >
> > End Sub
> >
> > --
> > Shelyons
>
>
date: Fri, 22 Aug 2008 10:21:00 -0700
author: Shelyons
Re: Cmd Button on Form for Filtered Report
Just above the doCmd.OpenReport line, add this line:
? strWhere
Run the report from your button. While it's still open, open the Immediate
Window (Ctrl+G), and see what came out. Does this filter string make sense?
It has to look exactly like the WHERE clause in a query.
Still in the Immediate Window, enter:
? Reports![warehouse_receipt2].Filter
Does this say the same thing?
Then try:
? Reports![warehouse_receipt2].FilterOn
Does it say, True?
If that works, the filter is being applied, so the problem may be with the
report, a subreport(?), or the source query.
--
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.
"Shelyons" wrote in message
news:610A501E-C818-443C-8732-9B71FEE7628C@microsoft.com...
> Mr. Browne - Thanks for the tips - unfortunity, I'm still getting all
> records
> and not the specific one's I need. :(
>
> this is driving me nuts because I know it's something simple...
>
> I've replaced my code with the example you provided...
>
> Private Sub cmdPrint_Click()
> Dim strWhere As String
>
> If Me.Dirty Then 'Save any edits.
> Me.Dirty = False
> End If
>
> If Me.NewRecord Then 'Check there is a record to print
> MsgBox "Select a record to print"
> Else
> strWhere = "[receipt#] = " & Me.[receipt#]
> DoCmd.OpenReport "warehouse_receipt2", acViewPreview, , strWhere
> End If
> End Sub
>
> Do you think maybe my report is set up wrong? Maybe the grouping? I
> don't
> know... I'm truely frusterated. My boss is starting to eyebrow me and I
> don't want to abandon this project to excel...
> --
> Shelyons
>
>
> "Allen Browne" wrote:
>
>> 1. Double-check that the report is not already open -- not even in design
>> view.
>>
>> 2. If you open your table in design view, what is the data type of your
>> receipt# field? If Number (not Text), lose the extra quotes.
>>
>> 3. Make sure the record is saved.
>>
>> 4. Make sure there is a record (form is not at a new record.
>>
>> 5. Use a string for the WhereCondition, so you can Debug.Print it to
>> check
>> the results.
>>
>> Further example:
>> http://allenbrowne.com/casu-15.html
>>
>> "Shelyons" wrote in message
>> news:963FABC8-0558-4418-992B-E2D873526D53@microsoft.com...
>> >I am using Access 2000. I am building a warehouse database that needs
>> >to
>> > produce a warehouse receipt. I have a form for the customer data which
>> > includes a subform for the product data. I have a cmd button that
>> > "should"
>> > create a report that is based on a query of both tables. I need the
>> > report
>> > to only be reflective of the for data currently displayed on the form.
>> > Instead I get a report that includes ALL records. Here is my code.
>> > Can
>> > you
>> > help?
>> >
>> > Private Sub CmdPrint_Click()
>> >
>> > Dim stDocName As String
>> >
>> > DoCmd.OpenReport "WAREHOUSE_RECEIPT2", acViewPreview, , "[receipt#] =
>> > '" &
>> > [receipt#] & "'"
>> >
>> >
>> >
>> > End Sub
date: Sat, 23 Aug 2008 10:24:27 +0800
author: Allen Browne lid
|
|