Filtering records "Automaticallly" with Query

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

OK, one problem solved (see thread on sorting numbers with dashes), one more
to go:

My databse incorporates comments from various people on various documents.

Once the comments are input, I want to be able to see a report of the
comments, but filtered so that ONLY a signle document's comments are
displayed.

What i have been doing (and it is somewhat of a pain) is to copy the
document title and paste it into the dialogue box that pops up due to my
query's use of
[Enter Title Name:] in the Criteria line of the query.

It would be nice if i could get the query to show just the entries of the
document which the user is currently "in" with the press of a button instead
of having to input a filter name (Document Title Name) in order to filter...

Am I stating the problem clear enough here or can I do better?

Thanks,

CCR
 
"document the user is in"?

Do you mean that you want to click a button on a form and have a report pop
up that only shows the record on that form? If so, do something similar to
the following for your button's code...


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 = "[ID] = " & Me.[ID]

DoCmd.OpenReport "MyReport", acViewPreview, , strWhere

End If

End Sub



Notes: If your primary key is a Text type field (not a Number type field),
you need extra quotes: strWhere = "[ID] = """ & Me.[ID] & """"

If you want the report to print without preview, replace acViewPreview with
acViewNormal.
 
Rick,

My DB takes "Editorial Comments" inputs from various people on various
documents.

What I really want to do is export these comments to Word [so I can get them
into a format that matches our headquarter's requirements...don't ASK!! ;- )
]. Now, currently, I have a couple of routines (macros) that do that fairly
nicely, the real problem lies in the query that filters all the various
documents comments.

Let me illustrate so you get a clearer picture of the problem:

Say I have 5 different people looking at 2 different documents: Doc A & Doc
B.

When the times comes that I want to export all the comments from everyone on
Doc A into a Word doc, I use the before stated Query Criteria and then have
to go thru cumbersome "cut & paste" hoops to get the doc title into the
dialogue box.

Not sure I understand your routine (I am NOT a coding genius...just an
amateur Access User)...

Ultimately, I need to adjust the query so that it only chooses the records
from the document titled Doc A (thereby eliminating the annoying dialogue
box!!) and somehow recognize that the user is in "Doc A's" records when they
click the "Export" button I have in that data entry form.

Does that clear things up or make it worse?

Thanks...

Rick B said:
"document the user is in"?

Do you mean that you want to click a button on a form and have a report pop
up that only shows the record on that form? If so, do something similar to
the following for your button's code...


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 = "[ID] = " & Me.[ID]

DoCmd.OpenReport "MyReport", acViewPreview, , strWhere

End If

End Sub



Notes: If your primary key is a Text type field (not a Number type field),
you need extra quotes: strWhere = "[ID] = """ & Me.[ID] & """"

If you want the report to print without preview, replace acViewPreview with
acViewNormal.



--
Rick B



CCR said:
OK, one problem solved (see thread on sorting numbers with dashes), one more
to go:

My databse incorporates comments from various people on various documents.

Once the comments are input, I want to be able to see a report of the
comments, but filtered so that ONLY a signle document's comments are
displayed.

What i have been doing (and it is somewhat of a pain) is to copy the
document title and paste it into the dialogue box that pops up due to my
query's use of
[Enter Title Name:] in the Criteria line of the query.

It would be nice if i could get the query to show just the entries of the
document which the user is currently "in" with the press of a button instead
of having to input a filter name (Document Title Name) in order to filter...

Am I stating the problem clear enough here or can I do better?

Thanks,

CCR
 

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

Back
Top