Duplicate Line When Printing Report (1 Viewer)

ErinL

Registered User.
Local time
Today, 11:34
Joined
May 20, 2011
Messages
118
Hi everyone -

I have posted this issue on this forum in the past so I apologize for posting it again but I have not found a solution and am getting to a point that I have to roll out this database and I need to get this resolved.

My issue is when there are 4 records (store numbers) for any "row" on the load diagram, the last store's information is duplicated when the report is printed. It only appears once in the table, it only appears once in the query, but when the report prints it prints two lines. It also does not include the duplicate line in the totals at the bottom of the report. This leads me to believe that the issue is in my PrintLines function which is in the modPrintLoadDiagram but I am only a beginner when writing code and have not been able to figure it out on my own.

I am attaching a version of the original database. Please open rptLoadDiagram in Print Preview and look at row 3 on the right side. Store 5449 is showing up twice but should only be on there one time.

This is the only issue holding up my roll out of the database.

Could someone please look at what I have attached?

I would appreciate any and all assistance. Thank you in advance.
 

Attachments

  • Database1.mdb
    656 KB · Views: 67

GinaWhipp

AWF VIP
Local time
Today, 12:34
Joined
Jun 21, 2011
Messages
5,899
That has been a problem with that code since I can remember... sorry, I have never found a solution and judging by the fact that it is still a problem I'm willing to bet others have found alternate solutions.
 

JHB

Have been here a while
Local time
Today, 18:34
Joined
Jun 17, 2012
Messages
7,732
What is the purpose of your code, what do you want to achieve, (if only to print 5 lines then the code doesn't work)?
 

vbaInet

AWF VIP
Local time
Today, 17:34
Joined
Jan 22, 2010
Messages
26,374
Yes, I believe the poster wants to have fixed number of rows. I will write one later (if you don't get there before JHB) and post.
 

vbaInet

AWF VIP
Local time
Today, 17:34
Joined
Jan 22, 2010
Messages
26,374
That has been a problem with that code since I can remember... sorry, I have never found a solution and judging by the fact that it is still a problem I'm willing to bet others have found alternate solutions.
I've never seen that particular code before! It doesn't look right.
 

JHB

Have been here a while
Local time
Today, 18:34
Joined
Jun 17, 2012
Messages
7,732
Replace the PrintLines function with the below code, then the function works for max. 4 Store-numbers:
Code:
Function PrintLines(R As Report, TotGrp)
   TotCount = TotCount + 1
   If TotCount = TotGrp Then
        R.NextRecord = False
   ElseIf TotCount > TotGrp And TotCount < 5 Then
        R.NextRecord = False
        R![RowNumber].Visible = False
        R![Position].Visible = False
        R![Store].Visible = False
        R![GreyTotes].Visible = False
        R![PlasticPallets].Visible = False
        R![PlasticStackers].Visible = False
        R![CardboardStackers].Visible = False
        R![ChepPallets].Visible = False
        R![PecoPallets].Visible = False
        R![IGPSPallets].Visible = False
        R![WoodPallets].Visible = False
        R![SmallBlueTotes].Visible = False
        R![Displays].Visible = False
   ElseIf TotCount >= 5 Then
        R![RowNumber].Visible = False
        R![Position].Visible = False
        R![Store].Visible = False
        R![GreyTotes].Visible = False
        R![PlasticPallets].Visible = False
        R![PlasticStackers].Visible = False
        R![CardboardStackers].Visible = False
        R![ChepPallets].Visible = False
        R![PecoPallets].Visible = False
        R![IGPSPallets].Visible = False
        R![WoodPallets].Visible = False
        R![SmallBlueTotes].Visible = False
        R![Displays].Visible = False
   End If
End Function
 

GinaWhipp

AWF VIP
Local time
Today, 12:34
Joined
Jun 21, 2011
Messages
5,899
@JHB

I agree, don't like it much either but it's used quite often.
 

vbaInet

AWF VIP
Local time
Today, 17:34
Joined
Jan 22, 2010
Messages
26,374
It's an effective piece of code though. I've attached two ways in which it can be done. The first one is similar to Microsoft's. The reports are srptLoadDiagramRight_New and srptLoadDiagramRight_New2
 

Attachments

  • Fixed_Rows5.mdb
    928 KB · Views: 48

ErinL

Registered User.
Local time
Today, 11:34
Joined
May 20, 2011
Messages
118
Thank you all so much for your help!!!

I replaced the original code with the code JHB posted and it works just how I want it to now! I racked my brain for so long on this :banghead: but, like I said, I'm a beginner and learning VBA code as I go so I'm nowhere near the level of expertise that you all have.

Thank you again for lifting that huge weight off my shoulders. :D
 

JHB

Have been here a while
Local time
Today, 18:34
Joined
Jun 17, 2012
Messages
7,732
You're welcome, luck with it, but have a look at what vbaInet has made, it is even better, because with his solution also the last line can be used.
 

ErinL

Registered User.
Local time
Today, 11:34
Joined
May 20, 2011
Messages
118
Ah! I do see that! That would give them another line to use. I will try implementing that too. Thanks again!
 

Users who are viewing this thread

Top Bottom