Hello there,
I am new at VBA and Access and I was making a DB that needs to print a determined number of different labels depending on the options given. When I use macros it is quite easy to choose the labels and it all works but I found out code that works fairly well and it becomes faster. But when I try to run a sequence of Ifs it does the first and stops not completing what I have in mind.
This is a little example but I think it is enough to understand. As you can see I try to open different reports when those numbers are higher than 0. But always stops on the first one and dont continue to open the others.
I would be appreciated if you could help
Edit. I don't know if this is the right place to post, since its Excel/VBA fórum and my question is directed to Access/VBA
I am new at VBA and Access and I was making a DB that needs to print a determined number of different labels depending on the options given. When I use macros it is quite easy to choose the labels and it all works but I found out code that works fairly well and it becomes faster. But when I try to run a sequence of Ifs it does the first and stops not completing what I have in mind.
Code:
If [XS] > 0 Then
DoCmd.OpenReport "Autocolante Etiqueta Adulto XS", acViewPreview, , "[Id_Encomenda]=" & [ID_Encomenda]
'Opens print dialog for current screen (report in this case):
DoCmd.RunCommand acCmdPrint
Me.Estado = "Impresso"
End If
If [S] > 0 Then
DoCmd.OpenReport "Autocolante Etiqueta Adulto S", acViewPreview, , "[Id_Encomenda]=" & [ID_Encomenda]
'Opens print dialog for current screen (report in this case):
DoCmd.RunCommand acCmdPrint
Me.Estado = "Impresso"
End If
If [M] > 0 Then
DoCmd.OpenReport "Autocolante Etiqueta Adulto M", acViewPreview, , "[Id_Encomenda]=" & [ID_Encomenda]
'Opens print dialog for current screen (report in this case):
DoCmd.RunCommand acCmdPrint
Me.Estado = "Impresso"
End If
This is a little example but I think it is enough to understand. As you can see I try to open different reports when those numbers are higher than 0. But always stops on the first one and dont continue to open the others.
I would be appreciated if you could help
Edit. I don't know if this is the right place to post, since its Excel/VBA fórum and my question is directed to Access/VBA
Last edited: