在Access VBA中,如何在报表上使用多个条件?

时间:2019-06-21 17:24:58

标签: vba ms-access access-vba ms-access-reports

我有以下无效的代码:

time: Jun,21,2019 09:40:00 AM   name: SV-North-PC   ip:
192.168.203.102    _FILES:  Array (
    [file] => Array
        (
            [name] => player_schedule.db3
            [type] => application/octet-stream
            [tmp_name] => /var/www/www-root/data/mod-tmp/phpYUCDQZ
            [error] => 0
            [size] => 9216
        )

)

time: Jun,21,2019 09:40:06 AM   name: SV-South-PC   ip:
192.168.203.103    _FILES:  Array (
    [file] => Array
        (
            [name] => player_schedule.db3
            [type] => application/octet-stream
            [tmp_name] => /var/www/www-root/data/mod-tmp/phpG25EYe
            [error] => 0
            [size] => 7168
        )

)

time: Jun,21,2019 09:40:07 AM   name: SV-South-PC   ip:
192.168.203.103    _FILES:  Array (
    [file] => Array
        (
            [name] => player_schedule.db3
            [type] => application/octet-stream
            [tmp_name] => /var/www/www-root/data/mod-tmp/phpfTPhdC
            [error] => 0
            [size] => 7168
        )

)

time: Jun,21,2019 09:40:13 AM   name: SV-South-PC   ip:
192.168.203.103    _FILES:  Array (
    [file] => Array
        (
            [name] => player_schedule.db3
            [type] => application/octet-stream
            [tmp_name] => /var/www/www-root/data/mod-tmp/phppqHvD6
            [error] => 0
            [size] => 10240
        )

)

time: Jun,21,2019 09:40:13 AM   name: SV-South-PC   ip:
192.168.203.103    _FILES:  Array (
    [file] => Array
        (
            [name] => player_schedule.db3
            [type] => application/octet-stream
            [tmp_name] => /var/www/www-root/data/mod-tmp/phpqhOHFH
            [error] => 0
            [size] => 10240
        )

)

time: Jun,21,2019 09:40:21 AM   name: SV-North-PC   ip:
192.168.203.102    _FILES:  Array (
    [file] => Array
        (
            [name] => player_schedule.db3
            [type] => application/octet-stream
            [tmp_name] => /var/www/www-root/data/mod-tmp/phpN0DdNK
            [error] => 0
            [size] => 7168
        )

)

time: Jun,21,2019 09:40:21 AM   name: SV-North-PC   ip:
192.168.203.102    _FILES:  Array (
    [file] => Array
        (
            [name] => player_schedule.db3
            [type] => application/octet-stream
            [tmp_name] => /var/www/www-root/data/mod-tmp/phpVIiSuD
            [error] => 0
            [size] => 7168
        )

)

time: Jun,21,2019 09:40:30 AM   name: SV-North-PC   ip:
192.168.203.102    _FILES:  Array (
    [file] => Array
        (
            [name] => player_schedule.db3
            [type] => application/octet-stream
            [tmp_name] => /var/www/www-root/data/mod-tmp/phphruWhV
            [error] => 0
            [size] => 9216
        )

)

time: Jun,21,2019 09:40:37 AM   name: SV-South-PC   ip:
192.168.203.103    _FILES:  Array (
    [file] => Array
        (
            [name] => player_schedule.db3
            [type] => application/octet-stream
            [tmp_name] => /var/www/www-root/data/mod-tmp/php6yH4Dj
            [error] => 0
            [size] => 7168
        )

)

time: Jun,21,2019 09:40:37 AM   name: SV-South-PC   ip:
192.168.203.103    _FILES:  Array (
    [file] => Array
        (
            [name] => player_schedule.db3
            [type] => application/octet-stream
            [tmp_name] => /var/www/www-root/data/mod-tmp/phpu2KuxL
            [error] => 0
            [size] => 7168
        )

)

time: Jun,21,2019 09:40:44 AM   name: SV-South-PC   ip:
192.168.203.103    _FILES:  Array (
    [file] => Array
        (
            [name] => player_schedule.db3
            [type] => application/octet-stream
            [tmp_name] => /var/www/www-root/data/mod-tmp/phphAbaWx
            [error] => 0
            [size] => 10240
        )

)

time: Jun,21,2019 09:40:44 AM   name: SV-South-PC   ip:
192.168.203.103    _FILES:  Array (
    [file] => Array
        (
            [name] => player_schedule.db3
            [type] => application/octet-stream
            [tmp_name] => /var/www/www-root/data/mod-tmp/phpR0RGMd
            [error] => 0
            [size] => 10240
        )

)

我希望该报告仅包含DoCmd.OpenReport "rptHome", acViewPreview, , "Room LIKE '*" & Room.Value & "*'" And "Flat LIKE '*" & Flat.Value & "*'" Room的记录。

但是,该代码在按如下方式使用时效果很好:

Flat

是否可以像我第一次尝试那样添加其他条件?

1 个答案:

答案 0 :(得分:0)

关键字“ AND ”必须但必须包含在条件中

DoCmd.OpenReport "rptHome", acViewPreview, , "Room LIKE '*" & Room.Value & "*' AND Flat LIKE '*" & Flat.Value & "*'`