Thema Datum  Von Nutzer Rating
Antwort
Rot Create A Query with a dynamic number of Properties
23.05.2017 10:08:26 Sönke
NotSolved
23.05.2017 10:33:20 SJ
NotSolved

Ansicht des Beitrags:
Von:
Sönke
Datum:
23.05.2017 10:08:26
Views:
880
Rating: Antwort:
  Ja
Thema:
Create A Query with a dynamic number of Properties

Dear Community, I am new with VBA, Programming a Access-Database. I try to create a query programmatically with a dynamic number and permutation of properties, Choosing by Checkboxes. The Problem is, that every Variation is possible. So My idea was to create a Variable that collect all expressions and then search in a table for it. An Example-Code is following

smyWert1 = "Select * from " & Me.Form.RecordSource & " where (([txt_Kategorie] = '" & Me.txt_Kategorie & "'))"

If ch_Wert = True Then
smyWert1 = "Select * from " & Me.Form.RecordSource & " where (([txt_Wert] = '" & Me.txt_Wert & "') And ([txt_Kategorie] = '" & Me.txt_Kategorie & "'))"
End If

My Idea is to replace the Expression (example: ([txt_Wert] = ' " & Me.txt_Wert & " ') ) with a variable, concatenate the expressions for all checked textboxes and at the end execute the select * from Command to search in the target-table.

I saw some tutorials to that topic but there was  no solution for my problem. There was also the difference to the tutorials, that I have to set the expression in ' " instead of ".

It would be greatful if someone can help me with this problem. I think it couldn't be so difficult but I don't find a solution in a short term period.

 

With kind regards

Sönke Schuch

 


Ihre Antwort
  • Bitte beschreiben Sie Ihr Problem möglichst ausführlich. (Wichtige Info z.B.: Office Version, Betriebssystem, Wo genau kommen Sie nicht weiter)
  • Bitte helfen Sie ebenfalls wenn Ihnen geholfen werden konnte und markieren Sie Ihre Anfrage als erledigt (Klick auf Häckchen)
  • Bei Crossposting, entsprechende Links auf andere Forenbeiträge beifügen / nachtragen
  • Codeschnipsel am besten über den Code-Button im Text-Editor einfügen
  • Die Angabe der Emailadresse ist freiwillig und wird nur verwendet, um Sie bei Antworten auf Ihren Beitrag zu benachrichtigen
Thema: Name: Email:



  • Bitte beschreiben Sie Ihr Problem möglichst ausführlich. (Wichtige Info z.B.: Office Version, Betriebssystem, Wo genau kommen Sie nicht weiter)
  • Bitte helfen Sie ebenfalls wenn Ihnen geholfen werden konnte und markieren Sie Ihre Anfrage als erledigt (Klick auf Häckchen)
  • Bei Crossposting, entsprechende Links auf andere Forenbeiträge beifügen / nachtragen
  • Codeschnipsel am besten über den Code-Button im Text-Editor einfügen
  • Die Angabe der Emailadresse ist freiwillig und wird nur verwendet, um Sie bei Antworten auf Ihren Beitrag zu benachrichtigen

Thema Datum  Von Nutzer Rating
Antwort
Rot Create A Query with a dynamic number of Properties
23.05.2017 10:08:26 Sönke
NotSolved
23.05.2017 10:33:20 SJ
NotSolved