Radosław Dumania

Radosław Dumania Senior Master Data
Analyst

Temat: User - defined function

Hey,

Mam funkcje w accessie - concatenate pola z roznych rekordow po przecinku (np. jablka, gruszki, czeresnie) . Dziala ok, z tymze po otrzymaniu wynikow przy np przewijaniu strony sie odswieza caly czas. Czy mozna dodac jakas komende to funkcji zeby przestala sie odwiezac ?

Public Function Conc(Fieldx, Identity, Value, Source) As Variant
Dim cnn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim SQL As String
Dim vFld As Variant
Dim i As Integer
Set cnn = CurrentProject.Connection
Set rs = New ADODB.Recordset
vFld = Null


SQL = "SELECT [" & Fieldx & "] as Fld" & _
" FROM [" & Source & "]" & _
" WHERE [" & Identity & "]='" & Value & "'"

' open recordset.
rs.Open SQL, cnn, adOpenForwardOnly, adLockReadOnly

' concatenate the field.
Do While Not rs.EOF
If Not IsNull(rs!Fld) Then
vFld = vFld & ", " & rs!Fld
End If
rs.MoveNext
Loop
' remove leading comma and space.
vFld = Mid(vFld, 3)

Set cnn = Nothing
Set rs = Nothing

' return concatenated string.
Conc = vFld
End Function
Dariusz Kolasa

Dariusz Kolasa Akademia VBA

Temat: User - defined function

do czego przypisujesz wynik tej funkcji?

Następna dyskusja:

Zmienna jako adres bibliote...




Wyślij zaproszenie do