Wrox Programmer Forums
|
BOOK: Access 2010 VBA Programmer's Reference
This is the forum to discuss the Wrox book Access 2010 Programmer's Reference by Teresa Hennig, Rob Cooper, Geoffrey L. Griffith, Jerry Dennison; ISBN: 978-0-470-59166-6
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Access 2010 VBA Programmer's Reference section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 4th, 2011, 12:11 PM
Registered User
 
Join Date: Apr 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default copying field properties

Hi,

I am trying out an example on page 377 and I notice that only a couple of field properties are included for creating new fields. The two properties that come up are .Required and .AllowZeroLength.

Well, my question is, if I am trying to synchronise fields of two tables from two different databases, is there an easy way to cover all the properties of a particular field.

For example: there is a tblCustomer table in DB1.accdb and tblCustomer table in DB2.accdb. I add an email field in tblCustomer of DB1, which is text, i specify validation property, format, size etc...

I now want to write a general module, which will read fields from both tables, find the differences in their design and add the extra fields in the tblCustomer of DB2 (with ALL the field properties)

What is the best method for doing this?
 
Old April 4th, 2011, 01:27 PM
Authorized User
 
Join Date: Oct 2010
Posts: 64
Thanks: 0
Thanked 16 Times in 16 Posts
Default

You need to enumerate the Properties collection. Here's a code snippet that may help.

Code:
Public Sub ListFieldProps(table As String)
    Dim db As DAO.Database
    Dim td As DAO.TableDef
    Dim fld As DAO.Field
    Dim prp As DAO.Property
    
    Set db = CurrentDb()
    
    On Error Resume Next
    Set td = db.TableDefs(table)
    
    If Err.Number = 0 Then 'table OK
        For Each fld In td.Fields
        Debug.Print fld.Name
            For Each prp In fld.Properties
                Debug.Print Chr(9) & prp.Name & " = "; prp.Value
            Next
        Next
    End If
    
    Set td = Nothing
    
End Sub
HTH.

Malc.

Last edited by malcolmdixon; April 4th, 2011 at 01:31 PM..
 
Old April 4th, 2011, 09:14 PM
Registered User
 
Join Date: Apr 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default thanks

hi Malcolm,

thank you very much. that is exactly what i was looking for.

cheers

dylan





Similar Threads
Thread Thread Starter Forum Replies Last Post
Copying and identifying field from one table to another easily rmccafferty Access 0 August 9th, 2009 04:37 PM
value properties in INPUT field roccosiffredi Ajax 2 May 6th, 2007 05:15 PM
Truncated field when copying Tachyophan Access VBA 3 November 16th, 2006 08:23 AM
Modify field properties in linked table RickD Access 1 September 8th, 2006 06:58 AM
Reading field properties from an Access database Anonymouse VB Databases Basics 0 October 29th, 2004 11:44 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.