Home  aadconsulting.com_ 

Access Extra No 21 July 2003_

  Access Tools and Databases AAD CONSULTING Sydney Australia_ | _Advanced Access Development
     
 What's New

Office 2003 News

Ezy SQL SQL Editor and Builder

A new Beta v1.3 of Ezy SQL  has been released. New features include the Unformatter Wizard, which parses a formatted SQL string variable from the clipboard or a module selection into SQL text.

FreeAccess Access Control Center

FreeAccess Access Control Center Beta v2.6 has been uploaded.

New features:

  • In-place editng of Database Names in the FACC tree
  • Drag files from Windows Explorer and automatically create shortcuts by dropping onto an Access version in FACC or a Task in the Task Pane
  • The Task Pane is now automatically refreshed after creating a task shortcut in FACC

Access KB Browser Article References

121 new articles this month

 Tips
Get the UNC Network Path

In Access, select a table and right-click. From the popup menu, click Create Shortcut...

In the Create Shortcut dialog, check the This Database is on the Network
checkbox, and you can then copy the full UNC network path from the Full Network textbox.

Get more tips, samples, articles and code from the

FreeAccess Access Utilities CD

Use the IIf Function for True-False Comparisons in Queries

The IIf function takes the following format:

IIf(Expression, TruePart, FalsePart)

Where:
  • Expression is the true-false comparison that you want to make
  • TruePart is the value returned if the comparison evaluates to True.
  • FalsePart is the value returned if the comparison evaluates to False.

For example, a field alias value can be set as follows in the field value of a column in the Access query by design grid:

Grade: IIf([Score] < 50, "Fail", "Pass")

Quick & Easy way to check if a Table Exists

Private Function CheckIfTableExists() As Boolean
' Returns True if table exists.
   
    Dim db As DAO.Database
    Dim rst As DAO.Recordset
   
    Set db = CurrentDb

   ' Try to open table to see if it exists.
    On Error Resume Next
    Set rst = db.OpenRecordset("uztblErrorLog")

    ' If there's no error, ie. table exists, returns True.
    If Err = 0 Then
        CheckIfTableExists = True
    Else
        CheckIfTableExists = False
    End If
   
End Function

This approach can be extended to other Access objects.

Neat way to make or distribute Registry Entries/Changes

For example, the following represents a Registry entry that sets IE as an off-line browser:

REGEDIT4
[HKEY_USERS\,DEFAULT\Software\Microsoft\Windows\CurrentVersion\Internet Settings]
"GlobalUserOffline"=1


A file association in Windows allows users to double-click a .reg file and then confirm the action, and merge the contents of the file into the local registry.  So, for example, you would save the above entry in  Notepad as a .reg file, and then double-click the file in Windows Explorer to update the Registry.

Caution: Back up the registry before making any changes.

Handy User Keyboard Shortcut

To re-enter a default value in a field: [Ctrl][Alt][Spacebar].

Downloads

ACC2000: Updated Version of Jet 4.0

Microsoft MS Access Downloads

Microsoft PowerToys for Windows XP

Jamie's Access Software

Microsoft Download Center

Microsoft Newsgroups

Microsoft Universal Data Access Download Page

TopXML, XML Products, XML Developer Library

Outlook Exchange Sample Applications


 Code Samples

imdCreate a Table in Code

It is tricky creating a table in code, as some field properties are not in the default collection, for example, the Format property, and have to be created by the developer. The following procedure creates a new table and demonstrates how to add a field property if it does not exist:

Private Sub CreateLogTable()
On Error GoTo Err_CreateLogTable
 
    Dim db As DAO.Database
    Dim tdfLog As TableDef
    Dim idxLog As Index
    Dim idxLogID As Field
    Dim obj As Object
    Dim prp As Property
   
    Const conPropNotFound As Integer = 3270
   
    Dim strPathName As String
    Dim strTableName As String
    Dim strTimeFieldName As String
 
'   Open the database
    'strPathName = "database.mdb"
    'Set db = OpenDatabase(strPathName)
    Set db = CurrentDb
   
    strTableName = "tblLog"
   
'   Create the table
    Set tdfLog = db.CreateTableDef(strTableName)
   
'   Create the index field
    Set idxLog = tdfLog.CreateIndex("PrimaryIndex")
    With idxLog
        .Fields.Append .CreateField("LogID", dbLong)
        .Primary = True
        .Required = True
    End With
   
    tdfLog.Indexes.Append idxLog
    tdfLog.Indexes.Refresh
   
'   Create fields
    With tdfLog
        .Fields.Append .CreateField("LogID", dbLong)
        .Fields("LogID").Attributes = .Attributes Or dbAutoIncrField
        .Fields.Append .CreateField("LogDate", dbDate)
        .Fields.Append .CreateField("LogTime", dbDate)
        .Fields.Append .CreateField("LogFacility", dbText, 50)
        .Fields.Append .CreateField("LogName", dbText, 50)
        .Fields.Append .CreateField("LogText", dbText, 255)
        .Fields.Append .CreateField("LogReported", dbText, 255)
        .Fields.Append .CreateField("LogOutcome", dbText, 255)
    End With
   
    db.TableDefs.Append tdfLog
    db.TableDefs.Refresh
   
    With tdfLog
        strTimeFieldName = "LogDate"
        Set obj = db.TableDefs(strTableName).Fields("LogDate")
        .Fields("LogDate").Properties("Format").Value = "Short Date"
        strTimeFieldName = "LogTime"
        Set obj = db.TableDefs(strTableName).Fields("LogTime")
        .Fields("LogTime").Properties("Format").Value = "Medium Time"
    End With
   
    dbRMS.TableDefs.Refresh
 
    Set obj = Nothing
    db.Close
 
Exit_CreateLogTable:
 
    Exit Sub
   
Err_CreateLogTable:
 
     If Err = conPropNotFound Then
        ' Create property, denote type, and set initial value
       
        Dim strProperty As String
        Dim strTimeFormat As String
       
        strProperty = "Format"
        If strTimeFieldName = "LogDate" Then
            strTimeFormat = "Short Date"
        Else
            strTimeFormat = "Medium Time"
        End If
       
        Set prp = obj.CreateProperty(
strProperty, dbText, _
            strTimeForma
t)
       
        ' Append Property object to Properties collection
        obj.Properties.Append prp
        obj.Properties.Refresh
       
        Resume Next
       
     Else
    
        MsgBox Err.Description, vbCritical, _
            "RMS Update Server (Create tblLog)"
        Resume Exit_CreateLogTable
       
     End If
 
End Sub

 Useful links

Microsoft Australia - TechNet Lounge

MS Office Product Documentation

Search the Knowledge Base

Smart Solutions

Using Dates and Times in Access 2000

VBDiamond Visual Basic Portal 

Outlook Exchange
 Coming soon...
  • 123 Global Error Handler Add-In Automatically adds global error-handling to all procedures in an .mdb and error-logging.

  • XML Explorer Add-In Explore XML documents with this Access Add-In. As XML documents are structured as trees of data, with this tool you can dig down into XML data using a Windows Explorer like interface.

  • Sticky Toolbar - an Access form-based Toolbar that moves with a form.
  \New Access KB Articles

Due to the large number of articles (152: 121 new and 31 updates) this month they are listed here.

These updates have been incorporated into the FreeAccess KB Browser database, which now has over 2,380 article references.

- Back Issues

No 20 June 2003
No 19 May 2003
No 18 April 2003
No 17
March 2003
No 16
February 2003
No 15
December 2002 / January 2003
No 14
November 2002
No 13
October 2002

Download a Searchable Compendium of Issues 1-12  

Visit our Link Partner:
Superior Software for Windows
Access, SQLServer and .NET Downloads

www.ssw.com.au
Top

Top

Editor: Tony D'Ambra
CONTENTS:
What's New
Tips
Downloads
Code Samples
Useful links
Coming soon...
New AccessKB Articles
Back Issues

Subscription to this newsletter is free.

This newsletter may contain links to sites or files on the Internet which are owned and operated by third parties. AAD CONSULTING is not responsible for the content of or files from any such third-party site.

Any files are provided "as is", without warranty of any kind. AAD CONSULTING does not assume any liability for use or the consequences of use.

To subscribe or unsubscribe from this mailing list, select a choice from combo-box below, enter your email address and click OK:

Have questions or comments?
Send them to us.

Access is a trademark of Microsoft Corporation.

©2001-2003
Anthony D'Ambra.
All rights reserved.

Top