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
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