User Tools

Site Tools


vba:access:functions:rownr

Differences

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

Link to this comparison view

Next revision
Previous revision
vba:access:functions:rownr [04.07.2018 09:19:30]
yaslaw created
vba:access:functions:rownr [04.07.2018 09:23:00] (current)
yaslaw [Beispiele]
Line 7: Line 7:
 </​const>​ </​const>​
  
-====== [VBA][Access] ​printRs() ====== +====== [VBA][Access] ​rowNr() ====== 
-//Gibt den Inhalt einer Tabelle/Abfrage/Recordsets im Textformat aus.//+//Generiert eine Zeilennumerierung für ein Abfrage//
  
 ==Version %%version%% (%%vdate%%)== ==Version %%version%% (%%vdate%%)==
- 
-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-Zwecke,​ um 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%%)}} 
- 
-===== Definition ===== 
-<WRAP center round important 60%> 
-Diese Funktion verwendet die Funktion [[vba:​functions:​printlist|]] 
-</​WRAP>​ 
- 
- 
-<​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, _ 
-        Optional ByVal iLimit As Integer = 10, _ 
-        Optional ByVal iReturn As enuPrintListOutputMethode = prListConsole,​ _ 
-        Optional ByRef oCancel As Boolean = False, _ 
-        Optional ByRef iFormats As Variant = Null _ 
-) As String</​code>​ 
-==== 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 
-  ***iLimit** <​Integer>​ (income)<​html><​br /></​html>​Maximal auszugebende Zeilen. Wenn die Zahl negativ ist, wird die Anzahl Zeilen vom Ende an ausgegeben 
-  ***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 
-  ***iFormats** Ein Array mit dFormaten um die Daten zu formatieren. Siehe auch format() von VBA 
  
 ===== Beispiele ===== ===== Beispiele =====
-Direkt im Immadiate-Window +<​code ​sql>SELECT ​  
-<​code ​vb>'​Resultat einer Abfrage + rownr(123t.id) 
-printrs "​vw_pivot_source"​ + t.* 
-| w1 | <> | 1 | 2 | 4 | +FROM tbl_data t 
-|----|----|---|---|---| +ORDER BY t.sort</​code>​
-| 1  |    | 2 |   ​| ​  | +
-| 2  |    |   | 1 |   | +
-| 3  |    |   | 1 | 1 | +
-| 4  | 0  |   ​| ​  ​| ​  | +
- +
-'Erste 5 Zeilen eines Recorsets +
-printrs currentdb.OpenRecordset("​my_table"​)+
-| ID | f_date ​             | f_string | f_double ​ | +
-|----|---------------------|----------|-----------| +
-| 1  | 14.03.2014 00:01:00 | abcd     | 1.15      | +
-| 2  | 23.06.2014 11:06:10 | bv       | 4         | +
-| 3  | 14.03.2014 00:03:00 | dd       | 165413.58 | +
-| 4  | 14.03.2014 00:17:00 | dsf      | 0.134     | +
-| 11 | 14.03.2014 00:10:00 |          | 0.5       | +
- +
-'​Rückgabe als String +
-?​printrs("​my_table"​5, prsReturn) +
-| ID | f_date ​             | f_string | f_double ​ | +
-|----|---------------------|----------|-----------| +
-| 1  | 14.03.2014 00:01:00 | abcd     | 1.15      | +
-| 2  | 23.06.2014 11:06:10 | bv       | 4         | +
-| 3  | 14.03.2014 00:03:00 | dd       | 165413.58 | +
-| 4  | 14.03.2014 00:17:00 | dsf      | 0.134     | +
-| 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 +
-| id | f_double ​  | +
-|----|------------| +
-| 3  | 165413.58 ​ | +
-| 22 | 16546.1654 | +
-| 25 | 8694.1 ​    | +
-| 12 | 156        | +
-| 18 | 151.584    |</​code>​+
  
 ===== Code ===== ===== Code =====
 <source '​%%fpath%%/​%%fname%%'​ vb> <source '​%%fpath%%/​%%fname%%'​ vb>
vba/access/functions/rownr.1530688770.txt.gz · Last modified: 04.07.2018 09:19:30 by yaslaw