Full Version: Printing One Record Of Subform
UtterAccess Forums > Microsoft® Access > Access Forms
Gadawg
I am using a database designed by someone else. It is set up without relationships. For example, one table has three fields: SupplementalID, CaseNumber,Narrative. There is a button to print a report based on same table with the following code from Allen Browne’s website:
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 = "[CaseID] = " & Me.[CaseID]
DoCmd.OpenReport "r_Supplemental", acViewPreview, , strWhere
End If
eing that One Case Number can have several different “Narratives” I am working on a new db with a relationship between two tables, basically as follows
Table 1 is named t_Case with the following
CaseID(autonumber)
CaseNo(text)
Table 2 is named t_Supplemental with the following
SupplementalID(autonumber)
Narrative(memo)
CaseID (number)
I have my relationship set up between CaseID in Table 1 and CaseID in Table 2. My main form is based on Table 1 and has one subform based on Table 2.
I have tried a few changes based on Allen Browne’s article about referring to subforms and replaced the [CaseID] with that but does not work. The report is have is set up based on Table 1 with a subreport on Table 2. As set up it print all records of Table 2 that are associated with Table1.
Any help is appreciated and thanks for looking.
projecttoday
What happens when you preview the entire report? Is it correct?
Gadawg
It prints all the records associated with the one case number.
projecttoday
Is that right or wrong? How is that different from your OpenReport version?
id you preview the whole report? (by right-clicking on the report in the navigation and selecting preview?)
Gadawg
I want to print only one record, the one selected in the form.
fkegley
Then you are going to have to use a value that is unique to the one selected in the form, such as the Primary Key, or possibly a combination of fields that together identify absolutely which record you want to print.
evise a query that uses the values in the various form controls that together identify the record currently being displayed on the form. Then base your report on that.
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.