Public Function RetSQLValue(strQuery As String) As Variant
Dim rsTmp As New ADODB.Recordset
On Error GoTo er_lab
Set rsTmp.ActiveConnection = cnnGDB
With rsTmp
.Source = ""
.MaxRecords = 1
.LockType = adLockOptimistic
.CursorLocation = adUseClient
.CursorType = adOpenKeyset
.Open strQuery, Options:=adCmdText
If .RecordCount > 0 Then
.MoveFirst
RetSQLValue = .Fields(0).Value
Else
RetSQLValue = Null
End If
End With
Set rsTmp = Nothing
GoTo ok_lab
er_lab:
RetSQLValue = "#ERROR#"
ok_lab:
End Function

Используются технологии uCoz