Results 1 to 6 of 6
  1. #1
    3 Star Lounger
    Join Date
    Oct 2001
    Location
    Newport, Gwent, Wales
    Posts
    257
    Thanks
    0
    Thanked 0 Times in 0 Posts

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

    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

  2. #2
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts

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

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

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

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

    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.

  4. #4
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts

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

    Obviously I needed a second glance! <img src=/S/blush.gif border=0 alt=blush width=15 height=15>
    Wendell

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

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

    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 =. <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

  6. #6
    3 Star Lounger
    Join Date
    Oct 2001
    Location
    Newport, Gwent, Wales
    Posts
    257
    Thanks
    0
    Thanked 0 Times in 0 Posts

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

    <img src=/S/doh.gif border=0 alt=doh width=15 height=15> 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.

    <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16> <img src=/S/clapping.gif border=0 alt=clapping width=19 height=23> <img src=/S/hailpraise.gif border=0 alt=hailpraise width=27 height=22>

    Ian

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •