By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,825 Members | 1,026 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,825 IT Pros & Developers. It's quick & easy.

Query current record

P: n/a
I am new to Access. I have a form with a single record. The keyed field is
PropID (number). I want to run a query from the form that will have the
current value of PropID be the variable in the criteria of the query. The
intent being the query returns the values of the current record of the form
for a report. So, I want to code a pushbutton to run that query with the
current keyed field value as the criteria and then open a report based on
that query. How do I do this in Access. I can do this in other desktop
RDBM programs.
Nov 13 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"Michael Israel" <mb***@spamlessoptonline.net> wrote in
news:og*********************@news4.srv.hcvlny.cv.n et:
I am new to Access. I have a form with a single record. The
keyed field is PropID (number). I want to run a query from
the form that will have the current value of PropID be the
variable in the criteria of the query. The intent being the
query returns the values of the current record of the form
for a report. So, I want to code a pushbutton to run that
query with the current keyed field value as the criteria and
then open a report based on that query. How do I do this in
Access. I can do this in other desktop RDBM programs.


Rather than put the query criteria in the recordsource of the
report, you can call the Docmd.openreport method with an optional
WHERE clause that filters the report recordsource.

So in the report calling code, first set up your criteria, then
pass that asa follows

Private sub CmdReportPvw_OnClick ()
Dim stReportname as string
Dim stwhereclause as string

streportname = "MyReport"
stwhereclause = "PropID = " & me.PropID ' For numeric ID
stwhereclause = "PropID = " & chr(34)& me.PropID & me.chr(34) '
For characeter ID

DoCmd.OpenReport streportname, , ,stwhereclause

End sub.
Bob Quintal

Nov 13 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.