Hey Everyone

I have a client who uses a Micrsoft Access Application for their business. One of the reports that the program has, is a label type report.

The report recieves the following parameters:

1. Number of blank labels to skip (should the user want to not print the first x number of labels
2. Invoice Number
3. Sub Order Number

2 and 3 are used to reference the relevant record in the relevant table

Each Job has a quantity of products that must be manufactured and thus 1 label must be printed for each (i.e. if the quantity of products for the job is 20, 20 labels must be printed). At the moment only 1 label is being placed on the report regardless of the quantity.

Below is the VBA code that is called when the report is opened. LabelSetup is called onOpen and LabelLayout is called onClick.

The program functioned correctly up until 2 weeks ago. To me it seems that some code from the LabelLayout function is missing but i don't know enough about VBA to be able to determine exactly what.

Option Compare Database

Option Explicit

Dim LabelBlanks&
Dim LabelCopies&
Dim BlankCount&
Dim CopyCount&

'===============================================
   ' The following function will cause an input box to
   ' display when the report is run that prompts the user
   ' for the number of used labels to skip and how many
   ' copies of each label should be printed.
'===============================================

Function LabelSetup()

   LabelBlanks& = Val(InputBox$("Enter Number of blank labels to skip"))
   'LabelCopies& = Val(InputBox$("Enter Number of Copies to Print"))
   If LabelBlanks& < 0 Then LabelBlanks& = 0
   If LabelCopies& < 1 Then LabelCopies& = 1
End Function

'===========================================================
   ' The following function sets the variables to a zero
'===========================================================

Function LabelInitialize()
   BlankCount& = 0
   CopyCount& = 0
End Function

'===========================================================
   ' The following function is the main part of this code
   ' that allows the labels to print as the user desires.
'===========================================================

Function LabelLayout(R As Report)
    
    
    If BlankCount& < LabelBlanks& Then
      R.NextRecord = False
      R.PrintSection = False
      BlankCount& = BlankCount& + 1
   Else
     ' CODE APPEARS TO BE MISSING FROM HERE
End If
   
End Function

I'll continue to research the problem myself but if anyone knows what i can do or has a suggestion of any kind, it would be greatly appreciated.

Regards
Laura

Okay, so I've managed to get it to print a specified number of labels by changing the code in LabelLayout to the following:

If BlankCount& < LabelBlanks& Then
      R.NextRecord = False
      R.PrintSection = False
      BlankCount& = BlankCount& + 1
      
    ElseIf CopyCount& < LabelCopies& - 1 Then
      R.PrintSection = True
      R.NextRecord = False
      CopyCount& = CopyCount& + 1
    End If

The problem now is that the report must automatically figure out the value of LabelCopies& by looking at the qunatity in the specific table, instead of taking it from the an input box:

LabelCopies& = Val(InputBox$("Enter Number of Copies to Print"))

Any idea's?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.