|
1
|
- Ken Getz
MCW Technologies, LLC
- keng@mcwtech.com
|
|
2
|
- Senior Consultant with MCW
Technologies
- Technical editor for
Access-VB-SQL Advisor
- Contributing editor for Microsoft
Office and VBA Developer
- Author of several developer’s
books on Access, VB, and VBA
- VB6 and Access video training
for AppDev (www.appdev.com)
- www.developershandbook.com
- E-mail: keng@mcwtech.com
|
|
3
|
- Derived from examples in Access 2002 Developer’s Handbook
- Paul Litwin, Ken Getz, and Mike Gunderloy
- Sybex, 2001
|
|
4
|
- Lots of Little Features
- Using the FileDialog Object
- Working with PivotChart/Table Views
- Managing Printer Settings
- Round-Tripping to Access 2000
|
|
5
|
- MouseWheel event
- Allows you to trap and handle the mouse wheel
- Tons of new events for PivotTable and PivotChart views
- Undo event (Forms and controls)
- Access 2000 added Dirty event
- Access 2002 adds Undo event (and Dirty event for some controls)
- Try frmCustomer
|
|
6
|
- Can open reports hidden, finally!
- OpenArgs applies to reports
- Reports handled more like forms
- Modal, popup, borderstyle
- AutoCenter and AutoSize
|
|
7
|
- AddItem and RemoveItem methods
- Finally, no more list-filling callback functions
- Must set RowSourceType to "Value List"
- Works only for unbound controls
- No Sorted property, however
- Try frmTestFileDialog
|
|
8
|
- Call AddItem method
- Multiple columns?
- Put ";" or "," between column values
- What if your data includes those?
|
|
9
|
- Call RemoveItem method
- Pass in index of item to be removed
- Can also pass in value of row to be removed
|
|
10
|
- No Clear method
- How do you clear the list?
- Clear the RowSource property:
|
|
11
|
- Lots of Little Features
- Using the FileDialog Object
- Working with PivotChart/Table Views
- Managing Printer Settings
- Round-Tripping to Access 2000
|
|
12
|
- Windows provides its own file open/save common dialog
- This isn’t it!
- The Office team provides its own wrapper around the common dialog
- Undocumented how to use it in previous versions of Access
|
|
13
|
- Now available as part of the MSO.DLL ActiveX component
- Set a reference to Microsoft Office 10.0 Object Library
- It’s a strange object!
- Try frmTestDialog
|
|
14
|
- Cannot instantiate a new instance
- Only a single instance allowed
- The FileDialog object requires a parameter when you reference it
- Must specify the type of dialog you want:
- File picker, Folder picker, Open, Save As
- Choose from one of four constants
|
|
15
|
- Call the Show method
- Returns True if you select a file or files
- Returns False if you cancel it
- Investigate SelectedItems property
- Returns a collection of selected items
- Contains strings—one per selected file or folder
- SelectedItems not cleared until the next time you call Show method
|
|
16
|
|
|
17
|
- DialogType (read-only)
- InitialView
- ButtonName
- Title
- AllowMultiselect
- InitialFileName
- Specify initially selected file, or initial folder
|
|
18
|
- Can specify one or more filters for the “Files of Type” combo box
- Filters property allows you to create collection of FileDialogFilter
objects
- You supply two properties for each:
- Can specify FilterIndex property to select initial filter
|
|
19
|
- Count property
- Add, Clear, Delete, Item methods
|
|
20
|
- Iterate through the SelectedItems
- Collection of strings
- From the demo:
|
|
21
|
- FileDialog object extremely limited
- Very few options
- Unless you need Office FileDialog's specific features, use Windows
FileOpen dialog box?
|
|
22
|
- Lots of Little Features
- Using the FileDialog Object
- Working with PivotChart/Table Views
- Managing Printer Settings
- Round-Tripping to Access 2000
|
|
23
|
- PivotTable and PivotChart added as form views
- Get rid of Microsoft Chart!
- Much like using the PivotTable and Chart controls from Office Web
Components, in Access 2000
- But much easier – all the data binding is done for you
- Binding those controls to forms was quite tricky
|
|
24
|
- PivotTable and PivotChart views take up the full form
- Want other controls too?
- Use subform containing new view, hosted on main form containing other
controls
- See frmPivotTableObjects
|
|
25
|
- Much like programming the OWC controls
- All examples using OWCs work with little change
- Object models changed slightly for new version
- Lots of new features added
|
|
26
|
- Use ChartSpace property of a form
- Charts collection provides reference to one or more charts on the form
|
|
27
|
- Unlike Microsoft Chart…
- PivotChart exposes full event model
- Can run code as mouse clicks or moves over elements
- Try frmChartEvents
- Move mouse over points
- Click on legend elements
|
|
28
|
- How do you know what kind of object the mouse is over?
- Use RangeFromPoint method in MouseMove event
- Returns the range the mouse was over
- Use TypeName to determine its type
|
|
29
|
- Use code like this to know what you moved over or clicked on:
|
|
30
|
- Tons of properties to work with
- Check object browser for more details
- See frmDemoPieChart for example
|
|
31
|
- Full control over every UI feature
- Can manage data
- Can create and manage layout
- See frmPivotTableObjects
|
|
32
|
- None of these programmatic features work unless the view is correct
- Check CurrentView property of form
- New constants added to support PivotTable view and PivotChart view
- Only use new programmatic features if the view is correct
|
|
33
|
- Lots of Little Features
- Using the FileDialog Object
- Working with PivotChart/Table Views
- Managing Printer Settings
- Round-Tripping to Access 2000
|
|
34
|
- After four versions…
- No more API calls to muck with printers
- Application.Printers provides collection of Printer objects
- Based on VB6's Printer object
|
|
35
|
- If you want to fill a list box with a list of all available printers:
|
|
36
|
- Set the Application object's Printer property to the selected printer
|
|
37
|
- To set Access' default printer to be Windows' default printer
- Set Application.Printer to Nothing
- Try frmSelectDefaultPrinter
|
|
38
|
- Forms and reports also support a Printer object
- Used when you indicate you want to print the object to a specific
printer
- Can set the Printer property of a form or report to a specific printer,
then print
- Better to have object print to default printer, and change Access'
default instead
- Example later…
|
|
39
|
- Print Layout properties:
- Bottom/Left/Top/RightMargin
- ItemSizeHeight/Width
- Row/ColumnSpacing
- ItemsAcross, ItemLayout
- DefaultSize, DataOnly
- Try frmPrintLayout
|
|
40
|
- Printer Name properties:
- DeviceName
- DriverName
- Port
- Try frmSetPrintDestination
|
|
41
|
- Print Job Properties:
- ColorMode
- Copies
- Duplex
- Orientation
- PaperBin
- PaperSize
- PrintQuality
- Try frmDevMode
|
|
42
|
- Two choices for individual objects:
- Change object's output destination
- Difficult to do, in general
- Change Access' default printer
- Requires that object be set up to print to default printer
|
|
43
|
- Steps:
- Open object
- Set new print destination
- Make sure object is selected
- DoCmd.PrintOut or DoCmd.OpenReport
- Doesn't require opening in Design view (so it works in MDE/ADE)
- Requires handling object twice
- Can't do the work from the Open event
|
|
44
|
|
|
45
|
- Steps:
- Set Access' Printer object to new destination
- Print object
- Set Access' Printer object to nothing
|
|
46
|
|
|
47
|
- Will only work if object is set up to print to default printer
- Investigate the UseDefaultPrinter property of an object
- Can set the property at runtime to override saved behavior
- But that leaves you handling the object twice again
|
|
48
|
- How do you know if a printer:
- Supports color?
- Supports duplex?
- Supports a specific paper size?
- Access doesn't provide this info
- Requires API
- See frmDevCaps for demo
|
|
49
|
- Lots of Little Features
- Using the FileDialog Object
- Working with PivotChart/Table Views
- Managing Printer Settings
- Round-Tripping to Access 2000
|
|
50
|
- Should work, in theory
- Stay in Access 2000 file format, and changes are OK
- What if you use programmatic features that don't work in Access 2000?
|
|
51
|
- Need to be able to determine the version of Access that's running
- Access 2002 provides Application.Version
- Not supported in Access 2000
- Use Syscmd instead:
|
|
52
|
- Can't use Printer object in Access 2000
- Can't use new methods/properties of objects in Access 2000
- In either case, code won't compile
- The answer: use late binding
|
|
53
|
- Instead of this:
- Use this:
|
|
54
|
- Instead of this:
- Use this:
|
|
55
|
- Use the version number to call new code (late bound) or old code:
|
|
56
|
- Lots of new programmability features
- Check object browser when you install
- Check new events, properties, and methods of existing objects
- Look for new objects
- Don't forget the Office type library, as well
- Lots of good stuff in there!
|
|
57
|
- Please don’t forget your evals
- Access 2002 Programmability Features
- Ken Getz
- keng@mcwtech.com
|