too many results!

jarheadjim

Registered User.
Local time
Today, 07:56
Joined
Mar 6, 2002
Messages
83
I have placed a command button on a form to open a report, but rather than show me just the information on that form, it gives me every record on the table. How do I make it just show the current information?

thanks
 
When you do the Open Report code pass a Where condition with it to limit the report.

Example:

Code:
DoCmd.OpenReport "Report Name", acViewPreview, , "[MyID]=" & Me.[IDField]
 
I'm afraid I don't understand, what is [myid] in the example? Wouldn't this prompt you for input?
 
let me see if i have this. I have it using an autonumber to be the primary key. this field is called [ReqNum]. so [myid]=[ReqNum], but what does [idfield]= ?, the name of the form that contains the field in question? sorry, i'm just not overly familiar with the lingo of database's. thanks for the help so far.
 
let me see if i have this. I have it using an autonumber to be the primary key. this field is called [ReqNum]. so [myid]=[ReqNum], but what does [idfield]= ?, the name of the form that contains the field in question? sorry, i'm just not overly familiar with the lingo of database's. thanks for the help so far.

[MyId] = the Field Name in the Query/Table
[Idfield] =[The Name of the Field with the ReqNum Value in it]
Me = the Current form that the code is on. It is a substitute for "Forms![Your Form Name]"

Code:
DoCmd.OpenReport "Report Name", acViewPreview, , "[ReqNum]=" & Me.[The Name of the Field with the ReqNum Value in it]
 
YAY

Got it! I think what was throwing me off was that [myid] & [idfield] happen to be the exact same thing in my case. It works fine now. Thank you all for your patience.
 

Users who are viewing this thread

Back
Top Bottom