| re: Access 2002: problem in VB function
Make sure you have set a reference to DAO (Tools - References from the VBE
window). And, you should begin disambigulating your variables:
Dim rst As ADODB.Recordset
Dim dbs As DAO.Database
--
Scott McDaniel
CS Computer Software
Visual Basic - Access - Sql Server - ASP
"Michael Dekson" <nospam@nospam.com> wrote in message
news:bseo27$84m$1@ariane.blic.net...[color=blue]
> In this VB function I have "Run-time error '3151' and debug is located at
> bold item (-->>).
>
> If you know what I do wrong please help me to solve this problem.
>
> Thanks
>
>
>
>
>
> Public Function get_cjena_imp(p_vccid As Integer, p_datum As Date)
>
> Dim RST As Recordset
>
> Dim db As Database
>
> Dim strSQL As String
>
>
>
> If Not IsNull(p_vccid) And Not IsNull(p_datum) Then
>
> Set db = CurrentDb
>
> 'strSQL = "SELECT P.CIJENA_IMPULSA FROM CRM_BIL_PARAMETRI AS P[/color]
WHERE[color=blue]
> P.VCC_ID= " & CStr(p_vccid) & " AND P.DATUM_OD=(SELECT MAX(P1.DATUM_OD)[/color]
FROM[color=blue]
> CRM_BIL_PARAMETRI P1 WHERE P1.VCC_ID = P.VCC_ID AND P1.DATUM_OD < " &
> "cdate('" & CStr(p_datum) & "'));"
>
> strSQL = "SELECT * FROM CRM_BIL_PARAMETRI"
>
> 'strSQL = "select * from stat"
>
> -->> Set RST = db.OpenRecordset(strSQL, dbOpenDynaset, dbReadOnly)
>
> If RST.EOF And RST.BOF Then
>
> Exit Function
>
> End If
>
>
>
> get_cjena_imp = RST![CIJENA_IMPULSA]
>
> 'db.Properties!AppTitle = "KASA - OPERATER: " & RST![Prezime]
>
> 'Application.RefreshTitleBar
>
> RST.Close
>
> Set db = Nothing
>
> 'PASS_OK = True
>
> DoCmd.Close
>
> Else
>
> MsgBox "Funkcija get_cjena_imp: jedan od parametara je prazan",
> vbCritical
>
>
>
> End If
>
>
>
> End Function
>
>[/color] |