skip a detail row???

G

Guest

I have a report detail that has nothing but a textbox and a few non-visible
textboxes. In the Format Detail section I have this code:

If Me.Phase <> Me.OldPhase Then sMessage = Me.CompanyName & " " &
Me.BrandName & " moved from " & Me.OldPhase & " to " & Me.Phase

If sMessage <> "" Then
Me.txtMessage = sMessage
Else
Me.txtMessage = ""
End If

What I am trying to do is only print something if the old and new phase is
different. Otherwise I want the report to look as though there was no record
and move on to the next row of data. Currently it leaves blank spaces in
those rows of the detail like this:

Company A moved from $0 to $200
Company B moved from $100 to $500



Company H moved from $150 to $400

Company D moved from $150 to $400

I'm trying for this:

Company A moved from $0 to $200
Company B moved from $100 to $500
Company H moved from $150 to $400
Company D moved from $150 to $400
 
G

Guest

OK I seemed to find a solution

I just added a Detail.Visible = False to the code when there is nothing I
want to show in the report for that line (record)
 
O

OfficeDev18 via AccessMonster.com

That's because you're essentially creating the report's data on the fly,
meaning that after the report's already open you're trying to tell Access
what data to report on and which to ignore. Don't do this, it's bad practice.
What you need to do is create a new temporary table with only the data you
want to report on, and then - and only then - open the report, setting the
report's Record Source to the new temporary table. After reporting, you can
delete the data or the table. Meanwhile, you have a table you can
troubleshoot for errors in your logic.

Hope this helps,

Sam
 
G

Guest

Hi,

I saw your message. I am not familiar with reports, but I am trying to
perform the same function like your if-else statement. Where in reports do
you put the code for that?
 

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