report filter (1 Viewer)

awake2424

Registered User.
Local time
Today, 06:32
Joined
Oct 31, 2007
Messages
479
Here is the report filter (form) properties window.

When I check the properties on the report the form is filtering it is blank.
 

Attachments

  • error.doc
    35.5 KB · Views: 85

Alc

Registered User.
Local time
Today, 07:32
Joined
Mar 23, 2007
Messages
2,407
Isee the problem - that one's just for the Combo Box on the Form.
You need the one on the Report itself.

Go to the Reports area of the MDB and open the report in question in design mode. Right click on the top, left corner to get the Properties window.
 

awake2424

Registered User.
Local time
Today, 06:32
Joined
Oct 31, 2007
Messages
479
I found it and set it to Yes. However the result returned is still not filtered by selection entered in the Case box (see attached). I select the case # and click the button and all the results are returned. I only need the selected entry to be returned. Thank you
 

Attachments

  • error.doc
    69.5 KB · Views: 76

unclejoe

Registered User.
Local time
Today, 19:32
Joined
Dec 27, 2004
Messages
190
If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If

The above code saves the current input record on the form.
If the current record is not save, you will not be able filter to this record as it is not in the table.

If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else

This code is not neccesary once the record is saved.

strWhere = "[Case number] = " & Me.[Case number]
DoCmd.OpenReport "unrelated SCT1", acViewPreview, , strWhere


Me.[Case number] is the current record you wish to print, just use the above to filter.

Note that you have [Case number] as an Integer but in your later post you have it as a String.


Currently I open the report in a form using this code:

Private Sub cmdPrint_Click()
Dim strWhere As String
If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[Case number] = " & Me.[Case number]
DoCmd.OpenReport "unrelated SCT1", acViewPreview, , strWhere
End If
End Sub

I am getting this error code: 2455 (screenshot attached)
 

awake2424

Registered User.
Local time
Today, 06:32
Joined
Oct 31, 2007
Messages
479
I am using this code:

Private Sub cmdPrint_Click()
Dim str_Filter As String
str_Filter = "[Case Number] = & Case"

If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If
DoCmd.OpenReport "unrelated SCT1", acViewNormal, str_Filter
End Sub

And I am getting error code: 2455 (screen shot attached)

I just want to be able to filter a report and save that filtered record to be printed. Thank you.
 

Attachments

  • error.doc
    28 KB · Views: 80

unclejoe

Registered User.
Local time
Today, 19:32
Joined
Dec 27, 2004
Messages
190
Is this correct? Can you confirm this?

Code:
str_Filter = "[Case Number] = & Case"

It should be...look at the qoutes

Code:
str_Filter = "[Case Number] = " & Case
If [Case Number] is integer/Long.

and

Code:
DoCmd.OpenReport "unrelated SCT1", acViewNormal, str_Filter
is "unrelated SCT1" correct? Should it be "unrelatedSCT1" without space?

The error indicates or possibly caused by another source? Please confirm by debuging the code by inserting break points into all the lines of the event button. Or insert a error trapping.

If there's no error from the button event, then it's from another source.

Else you may have a potential corruption. Can you do a compact and repair?

Edit: Case is a reserved word in access as ALC had indicated.

I am using this code:

Private Sub cmdPrint_Click()
Dim str_Filter As String
str_Filter = "[Case Number] = & Case"

If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If
DoCmd.OpenReport "unrelated SCT1", acViewNormal, str_Filter
End Sub

And I am getting error code: 2455 (screen shot attached)

I just want to be able to filter a report and save that filtered record to be printed. Thank you.
 
Last edited:

Users who are viewing this thread

Top Bottom