result set invalid use of property

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jagdip Singh Ajimal

    #1

    result set invalid use of property

    I have the following code

    Private dataEnviron As dataEnv
    Private DBconn As Connection

    Private Sub Class_Initializ e()
    Set dataEnviron = New dataEnv
    Set DBconn = dataEnviron.Ora cleConn
    DBconn.Open
    End Sub

    (1)Function getAppointments OnDate(ByVal appDate As Date) As Recordset
    Dim rs As Recordset
    Set rs = DBconn.Execute( "SELECT * FROM Appointments WHERE AppDate
    = " & appDate)
    (2) getAppointments OnDate = rs
    End Function


    But every time I try to run it, I get an "Invalid use of property"
    error with VB highlighting (1) in yellow and selecting (2).
    Can I return resultsets in this way?

    Any help would be appriciated

    Jagdip Singh Ajimal
  • Bob Butler

    #2
    Re: result set invalid use of property

    jsa1981@hotmail .com (Jagdip Singh Ajimal) wrote in message news:<c84eb1b0. 0402180545.5691 80d6@posting.go ogle.com>...
    <cut>[color=blue]
    > (1)Function getAppointments OnDate(ByVal appDate As Date) As Recordset
    > Dim rs As Recordset
    > Set rs = DBconn.Execute( "SELECT * FROM Appointments WHERE AppDate
    > = " & appDate)[/color]


    Set getAppointments OnDate = rs
    [color=blue]
    > End Function[/color]

    BTW, you need to format the date properly or it may not work on
    systems that have different local regional settings. Assuming SQL:

    sQuery = "SELECT * FROM Appointments WHERE AppDate = '" & _
    Format$(AppDate ,"yyyy-mm-dd") & "'"
    Set rs = DBconn.Execute( sQuery)

    You don't have to build the string separately but I find it helps
    debugging since you can stop on the Set statement and view the actual
    formatted query easily.

    Comment

    Working...