By Ken Bluttman
Book Price: $24.95 USD
£17.50 GBP
PDF Price: $19.99
Cover | Table of Contents | Colophon
AutoExec macro to run an opening function that delivers a personalized interface to the user. For this to work, you must first create a database table to store user preferences, and then, when the database starts up, you must be able to identify the user to the database. You can do this in a number of ways: for instance, a pop-up input box can ask for a name or initials (possibly with a password), a command-line switch can provide the user identity, or, if the Access security model is in use, the user ID can be made available through the CurrentUser property.|
Action
|
Keyboard shortcut
|
|---|---|
|
Enter the current time.
|
Ctrl-:
|
|
Enter the current date.
|
Ctrl-;
|
|
Insert data from the same field in the previous record.
|
Ctrl-'
|
|
Insert the default value for the field.
|
Ctrl-Alt-spacebar
|
|
Insert a new line in a text or memo field.
|
Ctrl-Enter
|
|
Enter a new record.
|
If…Then structure in VBA. This hack shows you how to transform a single macro into a multipurpose workhorse.End of Month function and the End of Month report are included in the processing only when it is the first day of the month (presumably tallying up figures about the month that just ended). Using the Day and Now functions takes care of testing for the first day of the month.DLookup function is true.open event. By putting a simple code routine into all
open events, you can populate a log with the names of the objects being opened. Before you do this, you need to create a log table to store the object names. This doesn't need to be fancy; indeed, the log table can have just a single field to store the names. Optional fields can store a timestamp, the type of object, and so forth.open event of a form named /ro switch at the end of the target string in the desktop shortcut. Note that the full target string isn't just the path to the database; it needs to start with the path to the Access executable, followed by the database path, followed by the switch."C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE" "C:\Sales Summaries\Sales2005.mdb" /ro
Insert operation in the database's opening routine, and you can include an extra table in the database for just this purpose. If the operation succeeds, the user is warned to use the desktop shortcut (as shown in Figure 1-18), and the database closes.
Append query to append records from one table to another. In a production environment in which data is always being shuffled around, using Append queries can become tedious. Each time you design one, you have to match the fields of the destination table with the fields of the source table. This is easy when the fields have the same name, but it takes manual intervention when the field names differ.Append query definition, and the source and destination tables never change in name or structure, all is well for you. However, if even a single extra character is misplaced or is missing in the field names, the query either bombs or asks you to fill in the value for the unidentifiable field. Neither is an option you can live with.
Append queries, they do have an advantage of their own: an Append query can use criteria to append filtered sets of records. Paste Append, on the other hand, just appends everything. However, if the need to apply criteria isn't an issue, Paste Append has the advantage.
?Application.CurrentData.AllTables.Count