
05-10-10, 10:28
|
 | Διαχειριστής Όνομα: Τάσος Φιλοξενιδης Έκδοση λογισμικού Office: Ms-Office 365 Γλώσσα λογισμικού Office: Ελληνική, Αγγλική, Γερμανική | | Εγγραφή: 21-10-2009
Μηνύματα: 2.035
| |
Καλημέρα σε όλους!
Αγαπητε Πάνο, η Access μας δινει τη δυνατότητα να ανοίγουμε αντικείμενα που περιέχουν δεδομένα χρησιμοποιώντας κριτήρια.
Αυτό κάνει ο κώδικας του προηγούμενου μηνύματος μου.
Η εξήγηση βρίσκεται στην παρακάτω ανάλυση: Κώδικας: Private Sub cmdOpenReport_Click()
On Error GoTo Err_cmdOpenReport_Click
' Αν υπάρξει λάθος θα μεταπηδήσει στη ρουτίνα Err_cmdOpenReport_Click παρακάτω.
Dim stDocName As String, strCriteria As String
' Δήλωση μεταβλητών.
' strCriteria= που θα χρησιμοποιηθούν με το άνοιγμα της έκθεσης
If Me.FilterOn Then strCriteria = Me.Filter
' Αν έχει εφαρμοστεί φίλτρο στη φόρμα, τότε ορίζεται στη μεταβλητή strCriteria
' ορίζεται ωςτιμή το φίλτρο που έχεις επιλέξει πχ.: " CustomerName='Πάνος' "
stDocName = "Qry1"
' το ονομα του αντικειμένου που θα ανοίξει.
' Τις μεταβλητες δεν είναι απαραίτητο να υπάρχουν όταν προκειται να χρησιμοποιηθούν
' μια ή δύο μόνο φορές στον κώδικα, εκτός και αν διεθκολύνουν τον ίδιο τον
' προγραμματιστή στην ανάγνωση και κατανόηση του κώδικα.
DoCmd.OpenReport stDocName, acViewReport, , strCriteria
' Πως ακριβώς λειτουργεί η εντολή DoCmd.OpenReport.. εξηγείται παρακάτω
Exit_cmdOpenReport_Click:
Exit Sub
Err_cmdOpenReport_Click:
MsgBox Err.Description
Resume Exit_cmdOpenReport_Click
End Sub
Από τη Microsoft: Παράθεση:
The OpenReport method carries out the OpenReport action in Visual Basic.
Syntax: expression.OpenReport(ReportName, View, FilterName, WhereCondition, WindowMode, OpenArgs) expression A variable that represents a DoCmd object. Parameters Name Required/Optional Data Type Description ReportName Required Variant
A string expression (string expression: An expression that evaluates to a sequence of contiguous characters.
Elements of the expression can be: functions that return a string or a string Variant (VarType 8);
a string literal, constant, variable, or Variant.) that's the valid name of a report in the current database.
If you execute Visual Basic code containing the OpenReport method in a library database
(library database: A collection of procedures and database objects that you can call from any application.
In order to use the items in the library, you must first establish a reference from the current database to the library database.),
Microsoft Access looks for the report with this name, first in the library database, then in the current database. View Optional AcView A AcView constant that specifies the view in which the report will open.
The default value is acViewNormal. FilterName Optional Variant A string expression that's the valid name
of a query (query: A question about the data stored in your tables, or a request to perform an action on the data.
A query can bring together data from multiple tables to serve as the source of data for a form or report.) in the current database. WhereCondition Optional Variant A string expression that's a valid SQL WHERE clause (WHERE clause:
The part of an SQL statement that specifies which records to retrieve.) without the word WHERE. WindowMode Optional AcWindowMode A AcWindowMode constant that specifies the mode in which the form opens.
The default valus is acWindowNormal. OpenArgs Optional Variant Sets the OpenArgs property. Remarks
You can use the OpenReport method to open a report in Design view (Design view:
A view that shows the design of these database objects: tables, queries, forms, reports, and macros.
In Design view, you can create new database objects and modify the design of existing objects.)
or Print Preview (print preview: A view of a document as it will appear when you print it.),
or to print the report immediately. You can also restrict the records
(record: A collection of data about a person, a place, an event, or some other item.
Records are the logical equivalents of rows in a table.) that are printed in the report.
The maximum length of the WhereCondition argument is 32,768 characters (unlike the Where Condition action argument in the Macro window, whose maximum length is 256 characters). Example
The following example prints Sales Report while using the existing query Report Filter.
Visual Basic for Applications
DoCmd.OpenReport "Sales Report", acViewNormal, "Report Filter"
| Καλή συνέχεια!
Τάσος
__________________ Ms-Office Development Team Ανάπτυξη επαγγελματικών εφαρμογών
Τελευταία επεξεργασία από το χρήστη Tasos : 05-10-10 στις 10:39.
|