Record specific query

Gerdagan

Registered User.
Local time
Today, 02:49
Joined
Mar 16, 2011
Messages
26
Hi everyone,

I have a database currently in use.

I want to create a query (from which I can create a report) to show me data relating one specific record, when run via a command button from the form where the selected record is active.

Basically, I have a form, where each record relates to one item of equipment. I have subdatasheets within the form displaying data about the item in question (all linked via a reference number).

I want to run a query from a command button that selects ONLY the data relating to this specific record and all the linked data. The query is in place, but I am having trouble figuring out how to view the data relating ONLY to the current record being viewed.

I hope that made sense.

Ged.
 
What you would do is create the query first but not based on only one main record. You would then create a report based on that query with the necessary grouping levels. Then from your form you would open the report (the query will run automatically when the report is opened) and filter the report using the reference number on the form for the currently displayed record. You would use the command button wizard and then you will need to edit the command it creates.
 
Hey, thanks for the reply. I have figured that bit out. It's what code I need to use in the command created that I am having trouble with. Do you know the code?

Thanks.
 
The command would go something like this:

Code:
DoCmd.OpenReport "YourReportNameHere", acViewPreview,,"UniqueFieldInQuery=" & me.ControlNameOnFormCorrespondingToUniqueField
 
Hey, thanks for that.

I've gotten this far before, so I know I am on the right path. However, when I run the command (by clicking on the command button in my form) I recieve a dialog box message requesting that I enter parameter value.

Any ideas on how I can resolve this?
 
The error could be due to a spelling error in your command or if the record source of the report involves a query that requires a parameter that could be causing it also.

First, can you post your actual code?

Second, what is the data type of the field you reference in the code?

Third, can you post the record source of the report?
 

Users who are viewing this thread

Back
Top Bottom