View Single Post
  #3 (permalink)  
Old May 31st, 2005, 11:54 AM
BrianWren BrianWren is offline
Friend of Wrox
 
Join Date: Nov 2004
Location: Port Orchard, WA, USA.
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Code:
Public Function get_last_id(what) As Double  ' What type of thing is “what”?

    Dim ds  As Database
    Dim myX As Double

    Set ds = OpenDatabase("c:\itc\bd\gestiuneIOMC.mdb")

    Select Case what
        Case Is = "ref"
            myX = ds.Execute("SELECT MAX(nrreferat) FROM tabelreferate;")
            ' don’t use a semi-colon in the SQL, above.
            MsgBox myX
            ds.Close
    End Select

End Function
Do you know which line returns the error?
If what is a string, the Case should be
Code:
        Case "ref"
Your .Execute statement returns a recordset (I’m pretty sure). A double can't hold a recordset.

If you want to do something really similar in syntax, create a function which returns a Double, say “MaxReferat(),” and within that function, return a recordset into a local variable, read the value of the one record, and return that as the function's return value. Then you would have:
Code:
        Case Is = "ref"
            myX = MaxReferat()
            MsgBox myX
Reply With Quote