🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.bazy-danych.msaccess
Article #137505

Wartości z jednej kolumny tabeli wielu rekordów

#137505
From: WieKo
Date: Fri, 25 Aug 2017 07:50
48 lines
2795 bytes
Wiem, że to już było kiedyś, ale znowu mam problem

Mam 1 tabelę tbFilie zawierającą adresy firm z polami:
tPaIDFilii | tPaNazwa |

i 2 tabelę tbTelefon zawierającą telefony firm z polami
tTelDFil | tTelNumer

Stworzyłem kwerendę, wykorzystującą funkcję DSumText autorstwa KN
SELECT tbFilie.tPaIDFilii, tbFilie.tPaNazwa, tbFilie.tPaMiejscowosc, tbTelefon.tTelNumer, DSumText([tTelNumer],[tbTelefon],"tPaIDFilii=" & [tPaIDFilii],[tPaIDFilii]) AS qTel, tbTelefon.tTelDFil
FROM tbFilie LEFT JOIN tbTelefon ON tbFilie.tPaIDFilii = tbTelefon.tTelDFil;

Chciałem, aby w polu 'qTel' pojawiły się wszystkie telefony danej firmy przedzielone przecinkiem.
Niestety, najpierw kwerenda żąda podania parametru '[tbTelefon]' a następnie wyświetla '#Błąd' w polu 'qTel'?

Co robię nie tak?

Użyta funcje to:
Public Function DSumText(sField As String, _
                  sTable As String, _
         Optional sWhere As String, _
         Optional sSep As String = ",") As Variant

  Dim rec As Recordset
  Dim strSQL As String
  Dim kon As String

  strSQL = "Select " & sField & " FROM " & sTable
  If Len(sWhere) > 0 Then
    strSQL = strSQL & " WHERE " & sWhere
  End If

  On Error GoTo err_exit
  Set rec = CurrentDb.OpenRecordset(strSQL, dbOpenSnapshot)
  With rec
    Do Until .EOF
      kon = kon & sSep & .Fields(0).Value
      .MoveNext
    Loop
    .Close
  End With
    kon = Mid(kon, Len(sSep) + 1)
    DSumText = kon
  Exit Function
err_exit:
End Function

Dziękuję za wyrozumiałość
Technical Details
Message-ID: <0ffce41a-81c2-443c-a1cc-8d12b7c848ba@googlegroups.com>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!agh.edu.pl!news.agh.edu.pl!newsfeed2.atman.pl!newsfeed.atman.pl!goblin3!goblin.stu.neva.ru!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!v29no305376qtv.0!news-out.google.com!f21ni389qta.1!nntp.google.com!e2no304851qta.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Received: by 10.129.52.75 with SMTP id b72mr1185537ywa.187.1503647457717;        Fri, 25 Aug 2017 00:50:57 -0700 (PDT)
X-Received: by 10.31.190.13 with SMTP id o13mr41691vkf.12.1503647457685; Fri, 25 Aug 2017 00:50:57 -0700 (PDT)
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!agh.edu.pl!news.agh.edu.pl!newsfeed2.atman.pl!newsfeed.atman.pl!goblin3!goblin.stu.neva.ru!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!v29no305376qtv.0!news-out.google.com!f21ni389qta.1!nntp.google.com!e2no304851qta.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
Newsgroups: pl.comp.bazy-danych.msaccess
Date: Fri, 25 Aug 2017 00:50:57 -0700 (PDT)
Complaints-To: groups-abuse@google.com
Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=88.199.174.66; posting-account=KS0f2woAAABY5xGyf6gP8jJ1YwQkOJN3
NNTP-Posting-Host: 88.199.174.66
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <0ffce41a-81c2-443c-a1cc-8d12b7c848ba@googlegroups.com>
Subject: Wartości z jednej kolumny tabeli wielu
 rekordów
From: WieKo <wiekoc68@gmail.com>
Injection-Date: Fri, 25 Aug 2017 07:50:57 +0000
Lines: 53
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit