🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Access 2010 łączenie kilku kryteriów do kwerendy

#137151
From: leku
Date: Sat, 30 Apr 2016 19:14
62 lines
3057 bytes

Użytkownik "MaciejF"  napisał w wiadomości grup 
dyskusyjnych:4e19ace0-0be4-4e68-9b5a-3d7d0c34e3c4@googlegroups.com...


Musisz tak sformatować sCond
By z wpisu jak zaciągasz do formularza
A1;B1;C1
by powstał wpis:
""A1"",""B1"",""C1""

Taki wpis trzeba przekazać do kwerendy

Proponuję:
sCond = """" & Replace(sCond, chr(59), """" & Chr(44) & """") & """"


Całość:

Sub btnPowiaty_click()
Dim sSQL As String, sCond As String
Dim qdf As DAO.Querydef

sCond = [Forms]![IMPORT]![kryt2]

IF IsNull(sCond) Or sCond = "" Then
Exit Sub
End IF

'sformatuj kryteria dodajac podwojne cudzysłowy
'uwzglednilem poniżej że masz separator średnik i że masz kryteria 
zaciagniete bez cudzysłowów

sCond = """" & Replace(sCond, chr(59), """" & Chr(44) & """") & """"
sSQL = "SELECT Imp_temp.F14 AS Powiat FROM Imp_temp WHERE (((Imp_temp.F14) 
In (" & sCond & ")));"

If DCount("*", "MSysObjects", "[Name] = qGeneric And [Type] = 5") = 1 Then
DoCmd.DeleteObject(acQuery, "qGeneric")
End If

Set qdf = CurrentDB.Querydefs("qGeneric")
qdf.SQL = sSQL
qdf.Execute


End Sub

----------------------------------------------------------------
Debug.Print sCond w oknie Immediate

daje

"A1 "," B1 "," C1"

Natomiast po wklejeniu całej procedury linijka

DoCmd.DeleteObject(acQuery, "qGeneric")

jest podświetlana na czerwono.
Przyznaję, że nie mam pojęcia co to jest za kwerenda systemowa qGeneric
Technical Details
Message-ID: <57250406$0$702$65785112@news.neostrada.pl>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!agh.edu.pl!news.agh.edu.pl!newsfeed2.atman.pl!newsfeed.atman.pl!goblin2!goblin1!goblin.stu.neva.ru!newsfeed.neostrada.pl!unt-exc-01.news.neostrada.pl!unt-spo-a-01.news.neostrada.pl!news.neostrada.pl.POSTED!not-for-mail
References: <571b871d$0$641$65785112@news.neostrada.pl> <073ae140-8104-4f0b-8178-a838692eda19@googlegroups.com> <5724847c$0$22828$65785112@news.neostrada.pl> <fdc4a38d-07f8-41f4-bb94-723d97a4c145@googlegroups.com> <fd443da0-eedc-4a0c-a73f-0db905d90224@googlegroups.com> <5724ddf1$0$658$65785112@news.neostrada.pl> <8aed9f36-9a23-43c1-b4a9-a6a820e54b3d@googlegroups.com> <eafa8aa8-8082-4adf-ab98-8f001100dcc3@googlegroups.com> <5724f365$0$22836$65785112@news.neostrada.pl> <4e19ace0-0be4-4e68-9b5a-3d7d0c34e3c4@googlegroups.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!agh.edu.pl!news.agh.edu.pl!newsfeed2.atman.pl!newsfeed.atman.pl!goblin2!goblin1!goblin.stu.neva.ru!newsfeed.neostrada.pl!unt-exc-01.news.neostrada.pl!unt-spo-a-01.news.neostrada.pl!news.neostrada.pl.POSTED!not-for-mail
From: "leku" <lekucz@wp.pl>
Newsgroups: pl.comp.bazy-danych.msaccess
References: <571b871d$0$641$65785112@news.neostrada.pl> <073ae140-8104-4f0b-8178-a838692eda19@googlegroups.com> <5724847c$0$22828$65785112@news.neostrada.pl> <fdc4a38d-07f8-41f4-bb94-723d97a4c145@googlegroups.com> <fd443da0-eedc-4a0c-a73f-0db905d90224@googlegroups.com> <5724ddf1$0$658$65785112@news.neostrada.pl> <8aed9f36-9a23-43c1-b4a9-a6a820e54b3d@googlegroups.com> <eafa8aa8-8082-4adf-ab98-8f001100dcc3@googlegroups.com> <5724f365$0$22836$65785112@news.neostrada.pl> <4e19ace0-0be4-4e68-9b5a-3d7d0c34e3c4@googlegroups.com>
In-Reply-To: <4e19ace0-0be4-4e68-9b5a-3d7d0c34e3c4@googlegroups.com>
Subject: Re: Access 2010 łączenie kilku
 kryteriów do kwerendy
Date: Sat, 30 Apr 2016 21:14:26 +0200
MIME-Version: 1.0
X-Priority: 3
X-MSMail-Priority: Normal
Importance: Normal
X-Newsreader: Microsoft Windows Live Mail 16.4.3528.331
X-MimeOLE: Produced By Microsoft MimeOLE V16.4.3528.331
Lines: 63
Message-ID: <57250406$0$702$65785112@news.neostrada.pl>
Organization: Telekomunikacja Polska
NNTP-Posting-Host: 79.186.216.205
X-Trace: 1462043654 unt-rea-a-01.news.neostrada.pl 702 79.186.216.205:62247
X-Complaints-To: abuse@news.neostrada.pl
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit