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

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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