• Invalid use of property, QueryDef problem. (Access 2k Win 2k)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Invalid use of property, QueryDef problem. (Access 2k Win 2k)

    Author
    Topic
    #407957

    Hello again everyone

    I have a problem with some VBA I’m trying to use, I’ve used the code before and it works fine, now it doesn’t so I’m obviously being thick….. Please let me know where I’ve missed the obvious.

    Here’s the code: –

    Dim strRecordCount As String
    Dim dBs As DAO.Database
    Dim Rst As DAO.Recordset
    Dim qryDef As DAO.QueryDef

    Set dBs = CurrentDb
    Set qryDef = dBs.QueryDefs(“MonthsInPeriod1Qry”)
    qryDef.Parameters = (“[Forms]![DateCtlFrm]![StartDateTxt]”) = Forms![DateCtlFrm]![StartDateTxt]
    qryDef.Parameters = (“[Forms]![DateCtlFrm]![StopDateTxt]”) = Forms![DateCtlFrm]![StopDateTxt]
    Set Rst = dBs.OpenRecordset(“MonthsInPeriod1Qry”)
    strRecordCount = Rst.RecordCount

    I get the error message “Invalid use of property” and the first .parameters is highlighted by the de######.

    My query has exactly the same parameters in its parameters section, I’ve checked and rechecked the bit after the = to ensure it is pointing at the right data, no luck.

    Please help..

    Thanks

    Ian

    Viewing 3 reply threads
    Author
    Replies
    • #857297

      At first glance, all appears to be in order. Is it possible that you are missing a DAO 3.6 reference?

    • #857298

      At first glance, all appears to be in order. Is it possible that you are missing a DAO 3.6 reference?

    • #857301

      There is an = too much. Instead of

      qryDef.Parameters = (“[Forms]![DateCtlFrm]![StartDateTxt]”) = Forms![DateCtlFrm]![StartDateTxt]

      use

      qryDef.Parameters(“[Forms]![DateCtlFrm]![StartDateTxt]”) = Forms![DateCtlFrm]![StartDateTxt]

      and similar for the other one.

      • #857311

        Obviously I needed a second glance! blush

        • #857319

          I did too – I started out to reply in the same vein as you did, but while I was composing my reply, I suddenly noticed the extra =. smile

          • #857678

            doh Thanks Hans, I’d got a feeling it was something of that ilk, but for the life of me (well for my sanity any way) I couldn’t see it.

            cheers clapping hailpraise

            Ian

          • #857679

            doh Thanks Hans, I’d got a feeling it was something of that ilk, but for the life of me (well for my sanity any way) I couldn’t see it.

            cheers clapping hailpraise

            Ian

        • #857320

          I did too – I started out to reply in the same vein as you did, but while I was composing my reply, I suddenly noticed the extra =. smile

      • #857312

        Obviously I needed a second glance! blush

    • #857302

      There is an = too much. Instead of

      qryDef.Parameters = (“[Forms]![DateCtlFrm]![StartDateTxt]”) = Forms![DateCtlFrm]![StartDateTxt]

      use

      qryDef.Parameters(“[Forms]![DateCtlFrm]![StartDateTxt]”) = Forms![DateCtlFrm]![StartDateTxt]

      and similar for the other one.

    Viewing 3 reply threads
    Reply To: Invalid use of property, QueryDef problem. (Access 2k Win 2k)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: