Sequency of IFs not working

ukalahs

New Member
Joined
Sep 11, 2013
Messages
1
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.

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:

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.

Forum statistics

Threads
1,215,491
Messages
6,125,099
Members
449,205
Latest member
ralemanygarcia

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top