Referencing a field's properties in a Report

L

LA Lawyer

I am running Access 2007 and am using code to open a report and make a lot
of changes to it, all of which works fine.

Now I want to hide duplicate data in a field in the details section. I have
used the following code:

"Reports!MajorEvents!CaseItemType.HideDuplicates = True"

I know that the reference to the report itself is correct since I have a
series of other references in the same snippet and they work. I am quite
sure that the reference to the HideDuplicates property is correct. My
belief that somewhere the reference has to be incorrect, but I can't see
where.

What is wrong with this? Is it the reference to a field in the details
section that is the problem?
 
A

Allen Browne

Suggestions:

1. Double-check that the name of the control is CaseItemType. Perhaps you a
field by that name, but the text box is actually called Text100 or
something. (You can't hide a 'field'; only a control.)

2. In design view, you can ask Access to tell you what kind of control it
is:
? TypeName(Reports!MajorEvents!CaseItemType)
? Reports!MajorEvents!CaseItemType.HideDuplicates

3. Use Me rather than the report name. The intellisense should show the
control name, and then the property name as you click the dot:
Debug.Print Me.CaseItemType.HideDuplicates
 
F

fredg

I am running Access 2007 and am using code to open a report and make a lot
of changes to it, all of which works fine.

Now I want to hide duplicate data in a field in the details section. I have
used the following code:

"Reports!MajorEvents!CaseItemType.HideDuplicates = True"

I know that the reference to the report itself is correct since I have a
series of other references in the same snippet and they work. I am quite
sure that the reference to the HideDuplicates property is correct. My
belief that somewhere the reference has to be incorrect, but I can't see
where.

What is wrong with this? Is it the reference to a field in the details
section that is the problem?

From Access 2002 VBA help on the HideDuplicates property:

"You can set the HideDuplicates property only in report Design view."

I would assume it's the same for Access 2007.

So if you are using code, you would have to open the report in design
view, use the above code to write the property value, then close and
save the report.

DoCmd.OpenReport "MajorEvents", acViewDesign
Reports!MajorEvents!CaseItemType.HideDuplicates = True
DoCmd.Close acReport, "MajorEvents", acSaveYes
 

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

Top