How to send parameters to microsoft access query so that I can import an access parameter query to excel?

前端 未结 3 828
耶瑟儿~
耶瑟儿~ 2021-01-24 00:42

I need to import a microsoft access query that has popup input parameters into excel. I tried the code below but it does not work. I receive error 93 that tells me that object o

相关标签:
3条回答
  • 2021-01-24 00:53

    You may have to pass valid date values to the parameters:

    qdf.Parameters("Date_PreviousMonth").Value = #12/31/2018#
    qdf.Parameters("Date_CurrentMonth").Value = #01/31/2019#
    
    0 讨论(0)
  • 2021-01-24 00:58

    Try adding square brackets around your parameters name so:

    qdf.Parameters("[" & "Date_PreviousMonth" & "]") = "31.12.2018"
    
    0 讨论(0)
  • 2021-01-24 01:07

    I tested setting query parameters via VBA with a very simple query and it works with following adjustments.

    1. query object must have PARAMETERS clause and parameters under appropriate field(s)

    2. use # delimiters for date criteria #12/31/2018#

    3. Set rst = qdf line does not use query name as argument, the variable qdf provides the name so correct to Set rst = qdf.OpenRecordset() which will use the default recordset type.

    4. for early binding, select Microsoft Office 14.0 Access Database Engine Object Library in VBA editor, at least for more recent versions of Excel

    0 讨论(0)
提交回复
热议问题