Macro to print report "n" times (Access)

2

First of all, thank you spend your time reading and / or answering my post. I'm new to forums as well as using Access.

I am developing a bbdd that allows me to print product labels, depending on a delivery note number.

I have created a macro that opens the report and prints the labels, but 1 unit of each.

The macro converted to VB is:

'------------------------------------------------------------
' Imprimir_Etiqueta_05
'
'------------------------------------------------------------
Function Imprimir_Etiqueta_05()
On Error GoTo Imprimir_Etiqueta_05_Err

DoCmd.OpenReport "Etiquetas Consulta Albarán", acViewNormal, "", "", acNormal


Imprimir_Etiqueta_05_Exit:
Exit Function

Imprimir_Etiqueta_05_Err:
MsgBox Error$
Resume Imprimir_Etiqueta_05_Exit

End Function

I need to print "n" labels, depending on the quantity ordered on each line of the delivery note. That data I have it in the query "Consulta Albaran", in a field called "Quantity Order"

I've been looking at the loops that exist, but I'm not sure which one suits my needs, or how to put it.

I would be very grateful if you could help me out.

Greetings

    
asked by Lauuszp 14.12.2018 в 13:22
source

1 answer

0

I had a similar problem a while ago and I solved it in the following way: 1. Create a table with numbers from 1 to the maximum number of delivery notes you can have (eg: Table [Numbers] field autonomic ID from 1 to 200 2. The report you have would have to be modified to link it to the table [Numbers] and that the union condition is Numbers.ID < = [Consult Albaran] .Quantity 3. The function that created you would have to modify it to accept as a parameter the delivery note number:

'------------------------------------------------------------
' Imprimir_Etiqueta_05
'
'------------------------------------------------------------
Function Imprimir_Etiqueta_05(NoAlbaran AS STRING)
On Error GoTo Imprimir_Etiqueta_05_Err

DoCmd.OpenReport "Etiquetas Consulta Albarán", acViewNormal, "", "<NoAlbaran>="""+NoAlbaran+"""", acNormal


Imprimir_Etiqueta_05_Exit:
Exit Function

Imprimir_Etiqueta_05_Err:
MsgBox Error$
Resume Imprimir_Etiqueta_05_Exit

End Function

I can not reproduce it but it should be something like that. Good luck and you'll tell us how it works for you.

    
answered by 02.01.2019 в 11:39