Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Removing duplication at format time

Status
Not open for further replies.

Cosette

Technical User
Nov 30, 2004
98
US
Hi all. I have two addresses. When they are the same, I want the second one not to show. So, in the 'On Format' Event of the report, I wrote the following code:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If [tblParent_1.Address] = [tblParent.Address] Then
[tblParent_1.Address] = ""
Else: [tblParent_1.Address] = [tblParent_1.Address]
End If
End Sub

The error I get is: Can't assign a value to this object. I have tried to change "" to null, same problem. I then tried to define a string variable, and still ran into the same issue. Any help is very welcomed.

Thanks

David
 
Hi
Have you looked at Conditional formatting? It may suit.
 
What you are trying to do is change the value of a field in a record at report time. From your description that is not your intention at all and Access stops you from doing this because queries used for reports are read-only snapshots.

You will need to either improve your query to not provide the duplicates if possible or think about hiding the field (rather than changing the value).

Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
  Static last_address
  If [tblParent.Address] = last_address Then
    AddressTextBox.visible=False 
  Else
    AddressTextBox.visible=True
  End if
  last_address=[tblParent.Address]
End Sub

 
PC,

Thank you. I had tried yesterday to play with the visible option but Access wouldn't let me. I will try your code later this am. Is Static an access key word?

David
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top