Displaying only records that meet a critera

B

BrentGrikis

Hello,

I have recently taken over administrating an Access 97 system with
reports and I have not worked with them before. I have been asked to
add a new report that shows all the same data as an existing report,
minus some data based on a field.
Example: Current report shows:
....
Type Description
Type 1 One
Type 1A One A
Type 2 Two
....

The new report I am creating should only display records with a record
type of 1.

The control source is ="Type " & [TypeCode] on the existing report
I would have thought ="Type " & ([TypeCode]=1) might have worked, but
an error is displayed.
I have also tried modifying the
DoCmd.OpenReport stDocName, acPreview
line in the form the report is called from to
DoCmd.OpenReport stDocName, acPreview, , TypeCode = 1
but this also caused an error.

Any help would be much appreciated.

Thanks, Brent
 
D

Duane Hookom

It looks like TypeCode is text. If so, try:
DoCmd.OpenReport stDocName, acPreview, , "TypeCode = '1'"
I would probably add a combo box listing all TypeCode values and allow the
users to select one. Then use code like:

Dim strWhere as String
If Not IsNull(Me.cboTypeCode) Then
strWhere = "[TypeCode]='" & Me.cboTypeCode & "'"
End If
DoCmd.OpenReport stDocName, acPreview, , strWhere
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top