User Tools

Site Tools


vba:access:functions:printrs

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
vba:access:functions:printrs [17.04.2015 11:33:13]
yaslaw
vba:access:functions:printrs [18.08.2017 12:18:45] (current)
yaslaw
Line 1: Line 1:
 <​const>​ <​const>​
-    version=1.5.1 +    version=3.1.0 
-    vdate=09.04.2015+    vdate=16.08.2017
     fname=udf_printrs.bas     fname=udf_printrs.bas
     ns=%NAMESPACE% ​   ​     ns=%NAMESPACE% ​   ​
Line 8: Line 8:
  
 ====== [VBA][Access] printRs() ====== ====== [VBA][Access] printRs() ======
 +//Gibt den Inhalt einer Tabelle/​Abfrage/​Recordsets im Textformat aus.//
 +
 ==Version %%version%% (%%vdate%%)== ==Version %%version%% (%%vdate%%)==
  
-printRs() ist dazu gedacht, schnell die ersten X Zeilen ​eines DAO.Recordsets ins Immadiate-Window ​auszugeben. Das ist praktisch für Debug-Zwecke ​oder auch um Beispiele zu Funktionen zu dokumentieren.+printRs() ist dazu gedacht, schnell die ersten X Zeilen ​einer Quelle (Tabelle, Abfrage, Recordset etc) als fornatierten Text auszugeben. Das ist praktisch für Debug-Zweckeum Beispiele zu Funktionen zu dokumentieren ​oder um Tabelleninhalte/​Resultate in ein Forum zu posten. 
 + 
 +Wird zum Beispiel in der [[vba:​access:​classes:​sqlscript]] verwendet
  
 {{%%ns%%:​%%fname%%|Download %%fname%% (V-%%version%%)}} {{%%ns%%:​%%fname%%|Download %%fname%% (V-%%version%%)}}
  
 ===== Definition ===== ===== Definition =====
 +<WRAP center round important 60%>
 +Diese Funktion verwendet die Funktion [[vba:​functions:​printlist|]]
 +</​WRAP>​
  
-<​code>​printRs(DAO.Recordset [,limit]) 
-printRs(ADODB.Recordset [,limit]) 
-printRs(SELECT-Statement [,limit]) 
-printRs(tabellenname [,limit]) 
-printRs(viewname [,limit]) 
-printRs(QueryDef [,​limit])</​code>​ 
  
-<code vb>​Public Function ​printRs( _+<​code>​printRs(SELECT-Statement [,limit [,​returnType[,​ cancel[, iFormats]]]]) 
 +printRs(recordset [,limit [,​returnType[,​ cancel[, iFormats]]]]) 
 +printRs(tabellenname [,limit [,​returnType[,​ cancel[, iFormats]]]]) 
 +printRs(TableDef [,limit [,​returnType[,​ cancel[, iFormats]]]]) 
 +printRs(viewname [,limit [,​returnType[,​ cancel[, iFormats]]]]) 
 +printRs(QueryDef [,limit [,​returnType[,​ cancel[, iFormats]]]])</​code>​ 
 + 
 +<code vb>​Public Function ​printrs( _
         ByVal iRs As Variant, _         ByVal iRs As Variant, _
         Optional ByVal iLimit As Integer = 10, _         Optional ByVal iLimit As Integer = 10, _
-        Optional ByVal iReturn As enuPrintRsOutputMethode ​prsConsole, _ +        Optional ByVal iReturn As enuPrintListOutputMethode ​prListConsole, _ 
-        Optional ByRef oCancel As Boolean = False _+        Optional ByRef oCancel As Boolean = False, _ 
 +        Optional ByRef iFormats As Variant = Null _
 ) As String</​code>​ ) As String</​code>​
 ==== Parameter-Liste ==== ==== Parameter-Liste ====
   ***iRs** <​Variant>​ (income)<​html><​br /></​html>​Mark text as key press Das offene DAO.Recordset. Es wird als %%ByVal%% übergeben und verändert somit das Original nicht. Es kann ein Recordet, ein SELECT-Statement,​ Tabellenname oder Abfragename sein   ***iRs** <​Variant>​ (income)<​html><​br /></​html>​Mark text as key press Das offene DAO.Recordset. Es wird als %%ByVal%% übergeben und verändert somit das Original nicht. Es kann ein Recordet, ein SELECT-Statement,​ Tabellenname oder Abfragename sein
   ***iLimit** <​Integer>​ (income)<​html><​br /></​html>​Maximal auszugebende Zeilen. Wenn die Zahl negativ ist, wird die Anzahl Zeilen vom Ende an ausgegeben   ***iLimit** <​Integer>​ (income)<​html><​br /></​html>​Maximal auszugebende Zeilen. Wenn die Zahl negativ ist, wird die Anzahl Zeilen vom Ende an ausgegeben
-  ***iReturn** <enuPrintRsOutputMethode> (optional income)<​html><​br /></​html>​Art der Rückgabe: Standart ist das Direktfenster. Alternativ kann man auch als Rückgabewert der Funktion oder in den Zwieschnepseicher des PCs schreiben. Die Auswahlen lassen sich auch kombinieren: prConsole+prClipboard.+  ***iReturn** <[[vba:​functions:​printlist#​enuprintlistoutputmethode|enuPrintListOutputMethode]]> (optional income)<​html><​br /></​html>​Art der Rückgabe: Standart ist das Direktfenster. Alternativ kann man auch als Rückgabewert der Funktion oder in den Zwieschnepseicher des PCs schreiben. Die Auswahlen lassen sich auch kombinieren
   ***oCancel** <​Boolean>​ (Otional outgoing)<​html><​br /></​html>​Rückgabeflag,​ ob der Print_Rs aus einem Grund abgebrochen wurde   ***oCancel** <​Boolean>​ (Otional outgoing)<​html><​br /></​html>​Rückgabeflag,​ ob der Print_Rs aus einem Grund abgebrochen wurde
 +  ***iFormats** Ein Array mit dFormaten um die Daten zu formatieren. Siehe auch format() von VBA
  
-==== Enumerator ==== 
-=== enuPrintRsOutputMethode === 
-  
-Auswahl was mir der Analyse geschehen soll. Die Werte lassen sich mit + kombinieren 
-  ***prsConsole**(1) Die Ausgabe wird ins Direktfenster geschrieben 
-  ***prsReturn**(2) Die Ausgabe wird als Funktionsrückgabewert zurückgegeben 
-  ***prsClipboard**(4) Die Ausgabe wird in den Zwieschenspeicher geschrieben 
-  ***prsMsgBox**(8) Die Ausgabe wird als Popup ausgegeben 
 ===== Beispiele ===== ===== Beispiele =====
 Direkt im Immadiate-Window Direkt im Immadiate-Window
-<code vb>​printrs currentdb.OpenRecordset("​my_table"​),​ 5+<code vb>'​Resultat einer Abfrage 
 +printrs "​vw_pivot_source"​ 
 +| w1 | <> | 1 | 2 | 4 | 
 +|----|----|---|---|---| 
 +| 1  |    | 2 |   ​| ​  | 
 +| 2  |    |   | 1 |   | 
 +| 3  |    |   | 1 | 1 | 
 +| 4  | 0  |   ​| ​  ​| ​  | 
 + 
 +'Erste 5 Zeilen eines Recorsets 
 +printrs currentdb.OpenRecordset("​my_table"​),​ 5
 | ID | f_date ​             | f_string | f_double ​ | | ID | f_date ​             | f_string | f_double ​ |
 |----|---------------------|----------|-----------| |----|---------------------|----------|-----------|
Line 54: Line 66:
 | 11 | 14.03.2014 00:10:00 |          | 0.5       | | 11 | 14.03.2014 00:10:00 |          | 0.5       |
  
 +'​Rückgabe als String
 ?​printrs("​my_table",​ 5, prsReturn) ?​printrs("​my_table",​ 5, prsReturn)
 | ID | f_date ​             | f_string | f_double ​ | | ID | f_date ​             | f_string | f_double ​ |
Line 63: Line 76:
 | 11 | 14.03.2014 00:10:00 |          | 0.5       | | 11 | 14.03.2014 00:10:00 |          | 0.5       |
  
 +'​Direktes Auswerten eines SQL-Befehls
 printrs "​SELECT id, f_double FROM my_table ORDER BY f_double DESC", 5 printrs "​SELECT id, f_double FROM my_table ORDER BY f_double DESC", 5
 | id | f_double ​  | | id | f_double ​  |
vba/access/functions/printrs.1429263193.txt.gz · Last modified: 17.04.2015 11:33:13 by yaslaw